diff --git a/Source/Core/Core/HW/GCMemcard/GCIFile.cpp b/Source/Core/Core/HW/GCMemcard/GCIFile.cpp index 9707134749..fe9d3972a3 100644 --- a/Source/Core/Core/HW/GCMemcard/GCIFile.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCIFile.cpp @@ -22,10 +22,10 @@ bool GCIFile::LoadHeader() if (!save_file) return false; - INFO_LOG(EXPANSIONINTERFACE, "Reading header from disk for %s", m_filename.c_str()); + INFO_LOG_FMT(EXPANSIONINTERFACE, "Reading header from disk for {}", m_filename); if (!save_file.ReadBytes(&m_gci_header, sizeof(m_gci_header))) { - ERROR_LOG(EXPANSIONINTERFACE, "Failed to read header for %s", m_filename.c_str()); + ERROR_LOG_FMT(EXPANSIONINTERFACE, "Failed to read header for {}", m_filename); return false; } @@ -43,17 +43,17 @@ bool GCIFile::LoadSaveBlocks() if (!save_file) return false; - INFO_LOG(EXPANSIONINTERFACE, "Reading savedata from disk for %s", m_filename.c_str()); - u16 num_blocks = m_gci_header.m_block_count; + INFO_LOG_FMT(EXPANSIONINTERFACE, "Reading savedata from disk for {}", m_filename); + const u16 num_blocks = m_gci_header.m_block_count; const u32 size = num_blocks * BLOCK_SIZE; - u64 file_size = save_file.GetSize(); + const u64 file_size = save_file.GetSize(); if (file_size != size + DENTRY_SIZE) { - ERROR_LOG(EXPANSIONINTERFACE, - "%s\nwas not loaded because it is an invalid GCI.\n File size (0x%" PRIx64 - ") does not match the size recorded in the header (0x%x)", - m_filename.c_str(), file_size, size + DENTRY_SIZE); + ERROR_LOG_FMT(EXPANSIONINTERFACE, + "{}\nwas not loaded because it is an invalid GCI.\n File size ({:#x}) does not " + "match the size recorded in the header ({:#x})", + m_filename.c_str(), file_size, size + DENTRY_SIZE); return false; } @@ -61,7 +61,7 @@ bool GCIFile::LoadSaveBlocks() save_file.Seek(DENTRY_SIZE, SEEK_SET); if (!save_file.ReadBytes(m_save_data.data(), size)) { - ERROR_LOG(EXPANSIONINTERFACE, "Failed to read data from GCI file %s", m_filename.c_str()); + ERROR_LOG_FMT(EXPANSIONINTERFACE, "Failed to read data from GCI file {}", m_filename); m_save_data.clear(); return false; } diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp index 4ae8ced27e..c12d4e9819 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp @@ -889,7 +889,7 @@ GCMemcardImportFileRetVal GCMemcard::ImportFile(const DEntry& direntry, for (int i = 0; i < fileBlocks; ++i) { if (firstBlock == 0xFFFF) - PanicAlert("Fatal Error"); + PanicAlertFmt("Fatal Error"); m_data_blocks[firstBlock - MC_FST_BLOCKS] = saveBlocks[i]; if (i == fileBlocks - 1) nextBlock = 0xFFFF; diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp index 435bbad164..3735a97ad2 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp @@ -44,10 +44,10 @@ bool GCMemcardDirectory::LoadGCI(Memcard::GCIFile gci) { if (gci.m_gci_header.GCI_FileName() == already_loaded_gci.m_gci_header.GCI_FileName()) { - ERROR_LOG(EXPANSIONINTERFACE, - "%s\nwas not loaded because it has the same internal filename as previously " - "loaded save\n%s", - gci.m_filename.c_str(), already_loaded_gci.m_filename.c_str()); + ERROR_LOG_FMT(EXPANSIONINTERFACE, + "{}\nwas not loaded because it has the same internal filename as previously " + "loaded save\n{}", + gci.m_filename, already_loaded_gci.m_filename); return false; } } @@ -58,26 +58,27 @@ bool GCMemcardDirectory::LoadGCI(Memcard::GCIFile gci) const u16 num_blocks = gci.m_gci_header.m_block_count; if (num_blocks > 2043) { - ERROR_LOG(EXPANSIONINTERFACE, - "%s\nwas not loaded because it is an invalid GCI.\nNumber of blocks claimed to be %u", - gci.m_filename.c_str(), num_blocks); + ERROR_LOG_FMT( + EXPANSIONINTERFACE, + "{}\nwas not loaded because it is an invalid GCI.\nNumber of blocks claimed to be {}", + gci.m_filename, num_blocks); return false; } if (!gci.LoadSaveBlocks()) { - ERROR_LOG(EXPANSIONINTERFACE, "Failed to load data of %s", gci.m_filename.c_str()); + ERROR_LOG_FMT(EXPANSIONINTERFACE, "Failed to load data of {}", gci.m_filename); return false; } // reserve storage for the save file in the BAT - u16 first_block = m_bat1.AssignBlocksContiguous(num_blocks); + const u16 first_block = m_bat1.AssignBlocksContiguous(num_blocks); if (first_block == 0xFFFF) { - ERROR_LOG( + ERROR_LOG_FMT( EXPANSIONINTERFACE, - "%s\nwas not loaded because there are not enough free blocks on the virtual memory card", - gci.m_filename.c_str()); + "{}\nwas not loaded because there are not enough free blocks on the virtual memory card", + gci.m_filename); return false; } gci.m_gci_header.m_first_block = first_block; @@ -174,7 +175,7 @@ GCMemcardDirectory::GCMemcardDirectory(const std::string& directory, int slot, gci.m_dirty = false; if (!gci.LoadHeader()) { - ERROR_LOG(EXPANSIONINTERFACE, "Failed to load header of %s", filename.c_str()); + ERROR_LOG_FMT(EXPANSIONINTERFACE, "Failed to load header of {}", filename); continue; } @@ -329,7 +330,7 @@ s32 GCMemcardDirectory::Write(u32 dest_address, s32 length, const u8* src_addres { std::unique_lock l(m_write_mutex); if (length != 0x80) - INFO_LOG(EXPANSIONINTERFACE, "Writing to 0x%x. Length: 0x%x", dest_address, length); + INFO_LOG_FMT(EXPANSIONINTERFACE, "Writing to {:#x}. Length: {:#x}", dest_address, length); s32 block = dest_address / Memcard::BLOCK_SIZE; u32 offset = dest_address % Memcard::BLOCK_SIZE; s32 extra = 0; // used for write calls that are across multiple blocks @@ -377,7 +378,7 @@ s32 GCMemcardDirectory::Write(u32 dest_address, s32 length, const u8* src_addres m_last_block = SaveAreaRW(block, true); if (m_last_block == -1) { - PanicAlertT("Report: GCIFolder Writing to unallocated block 0x%x", block); + PanicAlertFmtT("Report: GCIFolder Writing to unallocated block {0:#x}", block); exit(0); } } @@ -397,12 +398,12 @@ void GCMemcardDirectory::ClearBlock(u32 address) { if (address % Memcard::BLOCK_SIZE) { - PanicAlertT("GCMemcardDirectory: ClearBlock called with invalid block address"); + PanicAlertFmtT("GCMemcardDirectory: ClearBlock called with invalid block address"); return; } - u32 block = address / Memcard::BLOCK_SIZE; - INFO_LOG(EXPANSIONINTERFACE, "Clearing block %u", block); + const u32 block = address / Memcard::BLOCK_SIZE; + INFO_LOG_FMT(EXPANSIONINTERFACE, "Clearing block {}", block); switch (block) { case 0: @@ -446,8 +447,8 @@ inline void GCMemcardDirectory::SyncSaves() { if (current->m_dir_entries[i].m_gamecode != Memcard::DEntry::UNINITIALIZED_GAMECODE) { - INFO_LOG(EXPANSIONINTERFACE, "Syncing save 0x%x", - Common::swap32(current->m_dir_entries[i].m_gamecode.data())); + INFO_LOG_FMT(EXPANSIONINTERFACE, "Syncing save {:#x}", + Common::swap32(current->m_dir_entries[i].m_gamecode.data())); bool added = false; while (i >= m_saves.size()) { @@ -467,15 +468,16 @@ inline void GCMemcardDirectory::SyncSaves() if ((gamecode != 0xFFFFFFFF) && (gamecode != new_gamecode)) { - PanicAlertT("Game overwrote with another games save. Data corruption ahead 0x%x, 0x%x", - Common::swap32(m_saves[i].m_gci_header.m_gamecode.data()), - Common::swap32(current->m_dir_entries[i].m_gamecode.data())); + PanicAlertFmtT( + "Game overwrote with another games save. Data corruption ahead {0:#x}, {1:#x}", + Common::swap32(m_saves[i].m_gci_header.m_gamecode.data()), + Common::swap32(current->m_dir_entries[i].m_gamecode.data())); } memcpy((u8*)&(m_saves[i].m_gci_header), (u8*)&(current->m_dir_entries[i]), Memcard::DENTRY_SIZE); if (old_start != new_start) { - INFO_LOG(EXPANSIONINTERFACE, "Save moved from 0x%x to 0x%x", old_start, new_start); + INFO_LOG_FMT(EXPANSIONINTERFACE, "Save moved from {:#x} to {:#x}", old_start, new_start); m_saves[i].m_used_blocks.clear(); m_saves[i].m_save_data.clear(); } @@ -487,8 +489,8 @@ inline void GCMemcardDirectory::SyncSaves() } else if ((i < m_saves.size()) && (*(u32*)&(m_saves[i].m_gci_header) != 0xFFFFFFFF)) { - INFO_LOG(EXPANSIONINTERFACE, "Clearing and/or deleting save 0x%x", - Common::swap32(m_saves[i].m_gci_header.m_gamecode.data())); + INFO_LOG_FMT(EXPANSIONINTERFACE, "Clearing and/or deleting save {:#x}", + Common::swap32(m_saves[i].m_gci_header.m_gamecode.data())); m_saves[i].m_gci_header.m_gamecode = Memcard::DEntry::UNINITIALIZED_GAMECODE; m_saves[i].m_save_data.clear(); m_saves[i].m_used_blocks.clear(); @@ -570,18 +572,19 @@ bool GCMemcardDirectory::SetUsedBlocks(int save_index) block = current_bat->GetNextBlock(block); if (block == 0) { - PanicAlertT("BAT incorrect. Dolphin will now exit"); + PanicAlertFmtT("BAT incorrect. Dolphin will now exit"); exit(0); } } - u16 num_blocks = m_saves[save_index].m_gci_header.m_block_count; - u16 blocks_from_bat = (u16)m_saves[save_index].m_used_blocks.size(); + const u16 num_blocks = m_saves[save_index].m_gci_header.m_block_count; + const u16 blocks_from_bat = static_cast(m_saves[save_index].m_used_blocks.size()); if (blocks_from_bat != num_blocks) { - PanicAlertT("Warning: Number of blocks indicated by the BAT (%u) does not match that of the " - "loaded file header (%u)", - blocks_from_bat, num_blocks); + PanicAlertFmtT( + "Warning: Number of blocks indicated by the BAT ({0}) does not match that of the " + "loaded file header ({1})", + blocks_from_bat, num_blocks); return false; } @@ -605,8 +608,8 @@ void GCMemcardDirectory::FlushToFile() // The save's header has been changed but the actual save blocks haven't been read/written // to // skip flushing this file until actual save data is modified - ERROR_LOG(EXPANSIONINTERFACE, - "GCI header modified without corresponding save data changes"); + ERROR_LOG_FMT(EXPANSIONINTERFACE, + "GCI header modified without corresponding save data changes"); continue; } if (save.m_filename.empty()) @@ -621,8 +624,10 @@ void GCMemcardDirectory::FlushToFile() default_save_name.insert(default_save_name.end() - 4, '0'); } if (File::Exists(default_save_name)) - PanicAlertT("Failed to find new filename.\n%s\n will be overwritten", - default_save_name.c_str()); + { + PanicAlertFmtT("Failed to find new filename.\n{0}\n will be overwritten", + default_save_name); + } save.m_filename = default_save_name; } File::IOFile gci(save.m_filename, "wb"); @@ -641,7 +646,7 @@ void GCMemcardDirectory::FlushToFile() ++errors; Core::DisplayMessage( fmt::format("Failed to write save contents to {}", save.m_filename), 4000); - ERROR_LOG(EXPANSIONINTERFACE, "Failed to save data to %s", save.m_filename.c_str()); + ERROR_LOG_FMT(EXPANSIONINTERFACE, "Failed to save data to {}", save.m_filename); } } } @@ -667,7 +672,7 @@ void GCMemcardDirectory::FlushToFile() const u32 gamecode = Common::swap32(save.m_gci_header.m_gamecode.data()); if (gamecode != m_game_id && gamecode != 0xFFFFFFFF && !save.m_save_data.empty()) { - INFO_LOG(EXPANSIONINTERFACE, "Flushing savedata to disk for %s", save.m_filename.c_str()); + INFO_LOG_FMT(EXPANSIONINTERFACE, "Flushing savedata to disk for {}", save.m_filename); save.m_save_data.clear(); } } diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp index 7e8a472c12..1c9691b310 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp @@ -45,7 +45,7 @@ MemoryCard::MemoryCard(const std::string& filename, int card_index, u16 size_mbi m_memcard_data = std::make_unique(m_memory_card_size); memset(&m_memcard_data[0], 0xFF, m_memory_card_size); - INFO_LOG(EXPANSIONINTERFACE, "Reading memory card %s", m_filename.c_str()); + INFO_LOG_FMT(EXPANSIONINTERFACE, "Reading memory card {}", m_filename); file.ReadBytes(&m_memcard_data[0], m_memory_card_size); } else @@ -69,7 +69,7 @@ MemoryCard::MemoryCard(const std::string& filename, int card_index, u16 size_mbi // Fills in the remaining blocks memset(&m_memcard_data[MC_HDR_SIZE], 0xFF, m_memory_card_size - MC_HDR_SIZE); - INFO_LOG(EXPANSIONINTERFACE, "No memory card found. A new one was created instead."); + INFO_LOG_FMT(EXPANSIONINTERFACE, "No memory card found. A new one was created instead."); } // Class members (including inherited ones) have now been initialized, so @@ -113,15 +113,15 @@ void MemoryCard::CheckPath(std::string& memcardPath, const std::string& gameRegi // If the old file exists we are polite and ask if we should copy it std::string oldFilename = filename; filename.replace(filename.size() - 4, 4, ext); - if (PanicYesNoT("Memory Card filename in Slot %c is incorrect\n" - "Region not specified\n\n" - "Slot %c path was changed to\n" - "%s\n" - "Would you like to copy the old file to this new location?\n", - isSlotA ? 'A' : 'B', isSlotA ? 'A' : 'B', filename.c_str())) + if (PanicYesNoFmtT("Memory Card filename in Slot {0} is incorrect\n" + "Region not specified\n\n" + "Slot {1} path was changed to\n" + "{2}\n" + "Would you like to copy the old file to this new location?\n", + isSlotA ? 'A' : 'B', isSlotA ? 'A' : 'B', filename)) { if (!File::Copy(oldFilename, filename)) - PanicAlertT("Copy failed"); + PanicAlertFmtT("Copy failed"); } } memcardPath = filename; // Always correct the path! @@ -178,12 +178,12 @@ void MemoryCard::FlushThread() // Note - file may have changed above, after ctor if (!file) { - PanicAlertT( - "Could not write memory card file %s.\n\n" + PanicAlertFmtT( + "Could not write memory card file {0}.\n\n" "Are you running Dolphin from a CD/DVD, or is the save file maybe write protected?\n\n" "Are you receiving this after moving the emulator directory?\nIf so, then you may " "need to re-specify your memory card location in the options.", - m_filename.c_str()); + m_filename); // Exit the flushing thread - further flushes will be ignored unless // the thread is recreated. @@ -214,7 +214,7 @@ s32 MemoryCard::Read(u32 src_address, s32 length, u8* dest_address) { if (!IsAddressInBounds(src_address)) { - PanicAlertT("MemoryCard: Read called with invalid source address (0x%x)", src_address); + PanicAlertFmtT("MemoryCard: Read called with invalid source address ({0:#x})", src_address); return -1; } @@ -226,7 +226,8 @@ s32 MemoryCard::Write(u32 dest_address, s32 length, const u8* src_address) { if (!IsAddressInBounds(dest_address)) { - PanicAlertT("MemoryCard: Write called with invalid destination address (0x%x)", dest_address); + PanicAlertFmtT("MemoryCard: Write called with invalid destination address ({0:#x})", + dest_address); return -1; } @@ -242,7 +243,7 @@ void MemoryCard::ClearBlock(u32 address) { if (address & (Memcard::BLOCK_SIZE - 1) || !IsAddressInBounds(address)) { - PanicAlertT("MemoryCard: ClearBlock called on invalid address (0x%x)", address); + PanicAlertFmtT("MemoryCard: ClearBlock called on invalid address ({0:#x})", address); return; } else diff --git a/Source/Core/Core/HW/SI/SI.cpp b/Source/Core/Core/HW/SI/SI.cpp index 89b1724bb9..348a16339b 100644 --- a/Source/Core/Core/HW/SI/SI.cpp +++ b/Source/Core/Core/HW/SI/SI.cpp @@ -14,6 +14,7 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" +#include "Common/Logging/Log.h" #include "Common/Swap.h" #include "Core/ConfigManager.h" #include "Core/CoreTiming.h" @@ -294,17 +295,18 @@ static void RunSIBuffer(u64 user_data, s64 cycles_late) { if (s_com_csr.TSTART) { - u32 request_length = ConvertSILengthField(s_com_csr.OUTLNGTH); - u32 expected_response_length = ConvertSILengthField(s_com_csr.INLNGTH); - std::vector request_copy(s_si_buffer.data(), s_si_buffer.data() + request_length); + const u32 request_length = ConvertSILengthField(s_com_csr.OUTLNGTH); + const u32 expected_response_length = ConvertSILengthField(s_com_csr.INLNGTH); + const std::vector request_copy(s_si_buffer.data(), s_si_buffer.data() + request_length); - std::unique_ptr& device = s_channel[s_com_csr.CHANNEL].device; - u32 actual_response_length = device->RunBuffer(s_si_buffer.data(), request_length); + const std::unique_ptr& device = s_channel[s_com_csr.CHANNEL].device; + const u32 actual_response_length = device->RunBuffer(s_si_buffer.data(), request_length); - DEBUG_LOG(SERIALINTERFACE, - "RunSIBuffer chan: %d request_length: %u expected_response_length: %u " - "actual_response_length: %u", - s_com_csr.CHANNEL, request_length, expected_response_length, actual_response_length); + DEBUG_LOG_FMT(SERIALINTERFACE, + "RunSIBuffer chan: {} request_length: {} expected_response_length: {} " + "actual_response_length: {}", + s_com_csr.CHANNEL, request_length, expected_response_length, + actual_response_length); if (expected_response_length != actual_response_length) { std::ostringstream ss; @@ -312,10 +314,10 @@ static void RunSIBuffer(u64 user_data, s64 cycles_late) { ss << std::hex << std::setw(2) << std::setfill('0') << (int)b << ' '; } - DEBUG_LOG( + DEBUG_LOG_FMT( SERIALINTERFACE, - "RunSIBuffer: expected_response_length(%u) != actual_response_length(%u): request: %s", - expected_response_length, actual_response_length, ss.str().c_str()); + "RunSIBuffer: expected_response_length({}) != actual_response_length({}): request: {}", + expected_response_length, actual_response_length, ss.str()); } // TODO: diff --git a/Source/Core/Core/HW/SI/SI_Device.cpp b/Source/Core/Core/HW/SI/SI_Device.cpp index dfe74b4f0e..f14118b815 100644 --- a/Source/Core/Core/HW/SI/SI_Device.cpp +++ b/Source/Core/Core/HW/SI/SI_Device.cpp @@ -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; } diff --git a/Source/Core/Core/HW/SI/SI_DeviceGBA.cpp b/Source/Core/Core/HW/SI/SI_DeviceGBA.cpp index ce215c17a4..71bffe8af6 100644 --- a/Source/Core/Core/HW/SI/SI_DeviceGBA.cpp +++ b/Source/Core/Core/HW/SI/SI_DeviceGBA.cpp @@ -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(m_next_action)); + ERROR_LOG_FMT(SERIALINTERFACE, "Unknown state {}\n", m_next_action); return 0; } diff --git a/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp b/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp index 024b3d6047..4cf332347b 100644 --- a/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp +++ b/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp @@ -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(&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(&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; } diff --git a/Source/Core/Core/HW/SI/SI_DeviceGCSteeringWheel.cpp b/Source/Core/Core/HW/SI/SI_DeviceGCSteeringWheel.cpp index b7cf8e963c..9e765f6493 100644 --- a/Source/Core/Core/HW/SI/SI_DeviceGCSteeringWheel.cpp +++ b/Source/Core/Core/HW/SI/SI_DeviceGCSteeringWheel.cpp @@ -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 diff --git a/Source/Core/Core/HW/SI/SI_DeviceKeyboard.cpp b/Source/Core/Core/HW/SI/SI_DeviceKeyboard.cpp index d32fac1455..404ecc4d01 100644 --- a/Source/Core/Core/HW/SI/SI_DeviceKeyboard.cpp +++ b/Source/Core/Core/HW/SI/SI_DeviceKeyboard.cpp @@ -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(buffer[0]); + const auto command = static_cast(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; } diff --git a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp index 862a4a49ad..802581ec99 100644 --- a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp @@ -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(data); + const auto& rpt = *reinterpret_cast(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(&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; diff --git a/Source/Core/Core/HW/WiimoteEmu/Encryption.cpp b/Source/Core/Core/HW/WiimoteEmu/Encryption.cpp index 9d60718e8d..30d0ac8316 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Encryption.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Encryption.cpp @@ -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); } diff --git a/Source/Core/Core/HW/WiimoteEmu/MotionPlus.cpp b/Source/Core/Core/HW/WiimoteEmu/MotionPlus.cpp index 76d4eb0948..93be125ca3 100644 --- a/Source/Core/Core/HW/WiimoteEmu/MotionPlus.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/MotionPlus.cpp @@ -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; } diff --git a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp index ccddee2244..43b7d1810e 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp @@ -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; } diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp index 48b69864d7..4a0db31d0d 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp @@ -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(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{}); diff --git a/Source/Core/Core/HW/WiimoteReal/IOAndroid.cpp b/Source/Core/Core/HW/WiimoteReal/IOAndroid.cpp index 657b072a28..6b0fb21d41 100644 --- a/Source/Core/Core/HW/WiimoteReal/IOAndroid.cpp +++ b/Source/Core/Core/HW/WiimoteReal/IOAndroid.cpp @@ -27,7 +27,7 @@ void WiimoteScannerAndroid::FindWiimotes(std::vector& found_wiimotes, found_wiimotes.clear(); found_board = nullptr; - NOTICE_LOG(WIIMOTE, "Finding Wiimotes"); + NOTICE_LOG_FMT(WIIMOTE, "Finding Wiimotes"); JNIEnv* env = IDCache::GetEnvForThread(); diff --git a/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp b/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp index 7fec2bd9a2..3597f2e34e 100644 --- a/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp +++ b/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp @@ -24,7 +24,7 @@ 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; } @@ -32,7 +32,7 @@ WiimoteScannerLinux::WiimoteScannerLinux() : m_device_id(-1), m_device_sock(-1) 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& 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& 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; diff --git a/Source/Core/Core/HW/WiimoteReal/IOWin.cpp b/Source/Core/Core/HW/WiimoteReal/IOWin.cpp index ba69ea01e4..0969b91d20 100644 --- a/Source/Core/Core/HW/WiimoteReal/IOWin.cpp +++ b/Source/Core/Core/HW/WiimoteReal/IOWin.cpp @@ -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(buf) + 1, (ULONG)(len - 1)); + const BOOLEAN result = + pHidD_SetOutputReport(dev_handle, const_cast(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& 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(GetReportSize(buf[1])); + const auto report_size = static_cast(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; } diff --git a/Source/Core/Core/HW/WiimoteReal/IOdarwin.mm b/Source/Core/Core/HW/WiimoteReal/IOdarwin.mm index de652db756..a5b2891a32 100644 --- a/Source/Core/Core/HW/WiimoteReal/IOdarwin.mm +++ b/Source/Core/Core/HW/WiimoteReal/IOdarwin.mm @@ -38,7 +38,7 @@ void WiimoteScannerDarwin::FindWiimotes(std::vector& found_wiimotes, 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 @@ void WiimoteScannerDarwin::FindWiimotes(std::vector& found_wiimotes, 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 @@ void WiimoteScannerDarwin::FindWiimotes(std::vector& found_wiimotes, 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,7 +131,8 @@ bool WiimoteDarwin::ConnectInternal() 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; } @@ -139,7 +140,7 @@ bool WiimoteDarwin::ConnectInternal() 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 @@ bool WiimoteDarwin::ConnectInternal() 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 @@ void WiimoteDarwin::DisconnectInternal() 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 @@ void WiimoteDarwin::EnablePowerAssertionInternal() 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 @@ void WiimoteDarwin::DisablePowerAssertionInternal() 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 WiimoteDarwin::DisablePowerAssertionInternal() - (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 WiimoteDarwin::DisablePowerAssertionInternal() 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 WiimoteDarwin::DisablePowerAssertionInternal() 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(); } diff --git a/Source/Core/Core/HW/WiimoteReal/IOhidapi.cpp b/Source/Core/Core/HW/WiimoteReal/IOhidapi.cpp index 1c92f1b048..5fc8317dc2 100644 --- a/Source/Core/Core/HW/WiimoteReal/IOhidapi.cpp +++ b/Source/Core/Core/HW/WiimoteReal/IOhidapi.cpp @@ -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& 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; diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp index d290bb1b07..c47700d13c 100644 --- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp +++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp @@ -126,7 +126,7 @@ void AddWiimoteToPool(std::unique_ptr 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(&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(&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& 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& 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 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) diff --git a/Source/Core/Core/IOS/DI/DI.cpp b/Source/Core/Core/IOS/DI/DI.cpp index 308d076543..591364e2a9 100644 --- a/Source/Core/Core/IOS/DI/DI.cpp +++ b/Source/Core/Core/IOS/DI/DI.cpp @@ -4,7 +4,6 @@ #include "Core/IOS/DI/DI.h" -#include #include #include @@ -76,13 +75,13 @@ IPCCommandResult DI::IOCtl(const IOCtlRequest& request) const u8 command = Memory::Read_U8(request.buffer_in); if (request.request != command) { - WARN_LOG( - IOS_DI, - "IOCtl: Received conflicting commands: ioctl 0x%02x, buffer 0x%02x. Using ioctl command.", - request.request, command); + WARN_LOG_FMT(IOS_DI, + "IOCtl: Received conflicting commands: ioctl {:#04x}, buffer {:#04x}. Using " + "ioctl command.", + request.request, command); } - bool ready_to_execute = !m_executing_command.has_value(); + const bool ready_to_execute = !m_executing_command.has_value(); m_commands_to_execute.push_back(request.address); if (ready_to_execute) @@ -99,7 +98,7 @@ void DI::ProcessQueuedIOCtl() { if (m_commands_to_execute.empty()) { - PanicAlert("IOS::HLE::Device::DI: There is no command to execute!"); + PanicAlertFmt("IOS::HLE::Device::DI: There is no command to execute!"); return; } @@ -120,7 +119,7 @@ std::optional DI::WriteIfFits(const IOCtlRequest& request, u32 val { if (request.buffer_out_size < 4) { - WARN_LOG(IOS_DI, "Output buffer is too small to contain result; returning security error"); + WARN_LOG_FMT(IOS_DI, "Output buffer is too small to contain result; returning security error"); return DIResult::SecurityError; } else @@ -134,8 +133,8 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) { if (request.buffer_in_size != 0x20) { - ERROR_LOG(IOS_DI, "IOCtl: Received bad input buffer size 0x%02x, should be 0x20", - request.buffer_in_size); + ERROR_LOG_FMT(IOS_DI, "IOCtl: Received bad input buffer size {:#04x}, should be 0x20", + request.buffer_in_size); return DIResult::SecurityError; } @@ -144,12 +143,12 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) switch (static_cast(request.request)) { case DIIoctl::DVDLowInquiry: - INFO_LOG(IOS_DI, "DVDLowInquiry"); + INFO_LOG_FMT(IOS_DI, "DVDLowInquiry"); DICMDBUF0 = 0x12000000; DICMDBUF1 = 0; return StartDMATransfer(0x20, request); case DIIoctl::DVDLowReadDiskID: - INFO_LOG(IOS_DI, "DVDLowReadDiskID"); + INFO_LOG_FMT(IOS_DI, "DVDLowReadDiskID"); DICMDBUF0 = 0xA8000040; DICMDBUF1 = 0; DICMDBUF2 = 0x20; @@ -166,19 +165,20 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) { const u32 length = Memory::Read_U32(request.buffer_in + 4); const u32 position = Memory::Read_U32(request.buffer_in + 8); - INFO_LOG(IOS_DI, "DVDLowRead: offset 0x%08x (byte 0x%09" PRIx64 "), length 0x%x", position, - static_cast(position) << 2, length); + INFO_LOG_FMT(IOS_DI, "DVDLowRead: offset {:#010x} (byte {:#011x}), length {:#x}", position, + static_cast(position) << 2, length); if (m_current_partition == DiscIO::PARTITION_NONE) { - ERROR_LOG(IOS_DI, "Attempted to perform a decrypting read when no partition is open!"); + ERROR_LOG_FMT(IOS_DI, "Attempted to perform a decrypting read when no partition is open!"); return DIResult::SecurityError; } if (request.buffer_out_size < length) { - WARN_LOG(IOS_DI, - "Output buffer is too small for the result of the read (%d bytes given, needed at " - "least %d); returning security error", - request.buffer_out_size, length); + WARN_LOG_FMT( + IOS_DI, + "Output buffer is too small for the result of the read ({} bytes given, needed at " + "least {}); returning security error", + request.buffer_out_size, length); return DIResult::SecurityError; } m_last_length = position; // An actual mistake in IOS @@ -189,25 +189,25 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) case DIIoctl::DVDLowWaitForCoverClose: // This is a bit awkward to implement, as it doesn't return for a long time, so just act as if // the cover was immediately closed - INFO_LOG(IOS_DI, "DVDLowWaitForCoverClose - skipping"); + INFO_LOG_FMT(IOS_DI, "DVDLowWaitForCoverClose - skipping"); return DIResult::CoverClosed; case DIIoctl::DVDLowGetCoverRegister: { - u32 dicvr = DICVR; - DEBUG_LOG(IOS_DI, "DVDLowGetCoverRegister 0x%08x", dicvr); + const u32 dicvr = DICVR; + DEBUG_LOG_FMT(IOS_DI, "DVDLowGetCoverRegister {:#010x}", dicvr); return WriteIfFits(request, dicvr); } case DIIoctl::DVDLowNotifyReset: - INFO_LOG(IOS_DI, "DVDLowNotifyReset"); + INFO_LOG_FMT(IOS_DI, "DVDLowNotifyReset"); ResetDIRegisters(); return DIResult::Success; case DIIoctl::DVDLowSetSpinupFlag: - ERROR_LOG(IOS_DI, "DVDLowSetSpinupFlag - not a valid command, rejecting"); + ERROR_LOG_FMT(IOS_DI, "DVDLowSetSpinupFlag - not a valid command, rejecting"); return DIResult::BadArgument; case DIIoctl::DVDLowReadDvdPhysical: { const u8 position = Memory::Read_U8(request.buffer_in + 7); - INFO_LOG(IOS_DI, "DVDLowReadDvdPhysical: position 0x%02x", position); + INFO_LOG_FMT(IOS_DI, "DVDLowReadDvdPhysical: position {:#04x}", position); DICMDBUF0 = 0xAD000000 | (position << 8); DICMDBUF1 = 0; DICMDBUF2 = 0; @@ -216,7 +216,7 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) case DIIoctl::DVDLowReadDvdCopyright: { const u8 position = Memory::Read_U8(request.buffer_in + 7); - INFO_LOG(IOS_DI, "DVDLowReadDvdCopyright: position 0x%02x", position); + INFO_LOG_FMT(IOS_DI, "DVDLowReadDvdCopyright: position {:#04x}", position); DICMDBUF0 = 0xAD010000 | (position << 8); DICMDBUF1 = 0; DICMDBUF2 = 0; @@ -225,59 +225,59 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) case DIIoctl::DVDLowReadDvdDiscKey: { const u8 position = Memory::Read_U8(request.buffer_in + 7); - INFO_LOG(IOS_DI, "DVDLowReadDvdDiscKey: position 0x%02x", position); + INFO_LOG_FMT(IOS_DI, "DVDLowReadDvdDiscKey: position {:#04x}", position); DICMDBUF0 = 0xAD020000 | (position << 8); DICMDBUF1 = 0; DICMDBUF2 = 0; return StartDMATransfer(0x800, request); } case DIIoctl::DVDLowGetLength: - INFO_LOG(IOS_DI, "DVDLowGetLength 0x%08x", m_last_length); + INFO_LOG_FMT(IOS_DI, "DVDLowGetLength {:#010x}", m_last_length); return WriteIfFits(request, m_last_length); case DIIoctl::DVDLowGetImmBuf: { - u32 diimmbuf = DIIMMBUF; - INFO_LOG(IOS_DI, "DVDLowGetImmBuf 0x%08x", diimmbuf); + const u32 diimmbuf = DIIMMBUF; + INFO_LOG_FMT(IOS_DI, "DVDLowGetImmBuf {:#010x}", diimmbuf); return WriteIfFits(request, diimmbuf); } case DIIoctl::DVDLowMaskCoverInterrupt: - INFO_LOG(IOS_DI, "DVDLowMaskCoverInterrupt"); + INFO_LOG_FMT(IOS_DI, "DVDLowMaskCoverInterrupt"); DVDInterface::SetInterruptEnabled(DVDInterface::DIInterruptType::CVRINT, false); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DI_INTERRUPT_MASK_COMMAND); return DIResult::Success; case DIIoctl::DVDLowClearCoverInterrupt: - DEBUG_LOG(IOS_DI, "DVDLowClearCoverInterrupt"); + DEBUG_LOG_FMT(IOS_DI, "DVDLowClearCoverInterrupt"); DVDInterface::ClearInterrupt(DVDInterface::DIInterruptType::CVRINT); return DIResult::Success; case DIIoctl::DVDLowUnmaskStatusInterrupts: - INFO_LOG(IOS_DI, "DVDLowUnmaskStatusInterrupts"); + INFO_LOG_FMT(IOS_DI, "DVDLowUnmaskStatusInterrupts"); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DI_INTERRUPT_MASK_COMMAND); // Dummied out return DIResult::Success; case DIIoctl::DVDLowGetCoverStatus: // TODO: handle resetting case - INFO_LOG(IOS_DI, "DVDLowGetCoverStatus: Disc %sInserted", - DVDInterface::IsDiscInside() ? "" : "Not "); + INFO_LOG_FMT(IOS_DI, "DVDLowGetCoverStatus: Disc {}Inserted", + DVDInterface::IsDiscInside() ? "" : "Not "); return WriteIfFits(request, DVDInterface::IsDiscInside() ? 2 : 1); case DIIoctl::DVDLowUnmaskCoverInterrupt: - INFO_LOG(IOS_DI, "DVDLowUnmaskCoverInterrupt"); + INFO_LOG_FMT(IOS_DI, "DVDLowUnmaskCoverInterrupt"); DVDInterface::SetInterruptEnabled(DVDInterface::DIInterruptType::CVRINT, true); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DI_INTERRUPT_MASK_COMMAND); return DIResult::Success; case DIIoctl::DVDLowReset: { const bool spinup = Memory::Read_U32(request.buffer_in + 4); - INFO_LOG(IOS_DI, "DVDLowReset %s spinup", spinup ? "with" : "without"); + INFO_LOG_FMT(IOS_DI, "DVDLowReset {} spinup", spinup ? "with" : "without"); DVDInterface::ResetDrive(spinup); ResetDIRegisters(); return DIResult::Success; } case DIIoctl::DVDLowOpenPartition: - ERROR_LOG(IOS_DI, "DVDLowOpenPartition as an ioctl - rejecting"); + ERROR_LOG_FMT(IOS_DI, "DVDLowOpenPartition as an ioctl - rejecting"); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DIFFERENT_PARTITION_COMMAND); return DIResult::SecurityError; case DIIoctl::DVDLowClosePartition: - INFO_LOG(IOS_DI, "DVDLowClosePartition"); + INFO_LOG_FMT(IOS_DI, "DVDLowClosePartition"); ChangePartition(DiscIO::PARTITION_NONE); return DIResult::Success; case DIIoctl::DVDLowUnencryptedRead: @@ -285,8 +285,8 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) const u32 length = Memory::Read_U32(request.buffer_in + 4); const u32 position = Memory::Read_U32(request.buffer_in + 8); const u32 end = position + (length >> 2); // a 32-bit offset - INFO_LOG(IOS_DI, "DVDLowUnencryptedRead: offset 0x%08x (byte 0x%09" PRIx64 "), length 0x%x", - position, static_cast(position) << 2, length); + INFO_LOG_FMT(IOS_DI, "DVDLowUnencryptedRead: offset {:#010x} (byte {:#011x}), length {:#x}", + position, static_cast(position) << 2, length); // (start, end) as 32-bit offsets // Older IOS versions only accept the first range. Later versions added the extra ranges to // check how the drive responds to out of bounds reads (an error 001 check). @@ -306,51 +306,51 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) return StartDMATransfer(length, request); } } - WARN_LOG(IOS_DI, "DVDLowUnencryptedRead: trying to read from an illegal region!"); + WARN_LOG_FMT(IOS_DI, "DVDLowUnencryptedRead: trying to read from an illegal region!"); return DIResult::SecurityError; } case DIIoctl::DVDLowEnableDvdVideo: - ERROR_LOG(IOS_DI, "DVDLowEnableDvdVideo - rejecting"); + ERROR_LOG_FMT(IOS_DI, "DVDLowEnableDvdVideo - rejecting"); return DIResult::SecurityError; // There are a bunch of ioctlvs that are also (unintentionally) usable as ioctls; reject these in // Dolphin as games are unlikely to use them. case DIIoctl::DVDLowGetNoDiscOpenPartitionParams: - ERROR_LOG(IOS_DI, "DVDLowGetNoDiscOpenPartitionParams as an ioctl - rejecting"); + ERROR_LOG_FMT(IOS_DI, "DVDLowGetNoDiscOpenPartitionParams as an ioctl - rejecting"); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DIFFERENT_PARTITION_COMMAND); return DIResult::SecurityError; case DIIoctl::DVDLowNoDiscOpenPartition: - ERROR_LOG(IOS_DI, "DVDLowNoDiscOpenPartition as an ioctl - rejecting"); + ERROR_LOG_FMT(IOS_DI, "DVDLowNoDiscOpenPartition as an ioctl - rejecting"); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DIFFERENT_PARTITION_COMMAND); return DIResult::SecurityError; case DIIoctl::DVDLowGetNoDiscBufferSizes: - ERROR_LOG(IOS_DI, "DVDLowGetNoDiscBufferSizes as an ioctl - rejecting"); + ERROR_LOG_FMT(IOS_DI, "DVDLowGetNoDiscBufferSizes as an ioctl - rejecting"); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DIFFERENT_PARTITION_COMMAND); return DIResult::SecurityError; case DIIoctl::DVDLowOpenPartitionWithTmdAndTicket: - ERROR_LOG(IOS_DI, "DVDLowOpenPartitionWithTmdAndTicket as an ioctl - rejecting"); + ERROR_LOG_FMT(IOS_DI, "DVDLowOpenPartitionWithTmdAndTicket as an ioctl - rejecting"); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DIFFERENT_PARTITION_COMMAND); return DIResult::SecurityError; case DIIoctl::DVDLowOpenPartitionWithTmdAndTicketView: - ERROR_LOG(IOS_DI, "DVDLowOpenPartitionWithTmdAndTicketView as an ioctl - rejecting"); + ERROR_LOG_FMT(IOS_DI, "DVDLowOpenPartitionWithTmdAndTicketView as an ioctl - rejecting"); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DIFFERENT_PARTITION_COMMAND); return DIResult::SecurityError; case DIIoctl::DVDLowGetStatusRegister: { - u32 disr = DISR; - INFO_LOG(IOS_DI, "DVDLowGetStatusRegister: 0x%08x", disr); + const u32 disr = DISR; + INFO_LOG_FMT(IOS_DI, "DVDLowGetStatusRegister: {:#010x}", disr); return WriteIfFits(request, disr); } case DIIoctl::DVDLowGetControlRegister: { - u32 dicr = DICR; - INFO_LOG(IOS_DI, "DVDLowGetControlRegister: 0x%08x", dicr); + const u32 dicr = DICR; + INFO_LOG_FMT(IOS_DI, "DVDLowGetControlRegister: {:#010x}", dicr); return WriteIfFits(request, dicr); } case DIIoctl::DVDLowReportKey: { const u8 param1 = Memory::Read_U8(request.buffer_in + 7); const u32 param2 = Memory::Read_U32(request.buffer_in + 8); - INFO_LOG(IOS_DI, "DVDLowReportKey: param1 0x%02x, param2 0x%06x", param1, param2); + INFO_LOG_FMT(IOS_DI, "DVDLowReportKey: param1 {:#04x}, param2 {:#08x}", param1, param2); DICMDBUF0 = 0xA4000000 | (param1 << 16); DICMDBUF1 = param2 & 0xFFFFFF; DICMDBUF2 = 0; @@ -359,8 +359,8 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) case DIIoctl::DVDLowSeek: { const u32 position = Memory::Read_U32(request.buffer_in + 4); // 32-bit offset - INFO_LOG(IOS_DI, "DVDLowSeek: position 0x%08x, translated to 0x%08x", position, - position); // TODO: do partition translation! + INFO_LOG_FMT(IOS_DI, "DVDLowSeek: position {:#010x}, translated to {:#010x}", position, + position); // TODO: do partition translation! DICMDBUF0 = 0xAB000000; DICMDBUF1 = position; return StartImmediateTransfer(request, false); @@ -371,8 +371,8 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) const u8 flag2 = Memory::Read_U8(request.buffer_in + 11); const u32 length = Memory::Read_U32(request.buffer_in + 12); const u32 position = Memory::Read_U32(request.buffer_in + 16); - INFO_LOG(IOS_DI, "DVDLowReadDvd(%d, %d): position 0x%06x, length 0x%06x", flag1, flag2, - position, length); + INFO_LOG_FMT(IOS_DI, "DVDLowReadDvd({}, {}): position {:#08x}, length {:#08x}", flag1, flag2, + position, length); DICMDBUF0 = 0xD0000000 | ((flag1 & 1) << 7) | ((flag2 & 1) << 6); DICMDBUF1 = position & 0xFFFFFF; DICMDBUF2 = length & 0xFFFFFF; @@ -383,41 +383,41 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) const u8 flag1 = Memory::Read_U8(request.buffer_in + 7); const u8 param2 = Memory::Read_U8(request.buffer_in + 11); const u32 position = Memory::Read_U32(request.buffer_in + 12); - INFO_LOG(IOS_DI, "DVDLowReadDvdConfig(%d, %d): position 0x%06x", flag1, param2, position); + INFO_LOG_FMT(IOS_DI, "DVDLowReadDvdConfig({}, {}): position {:#08x}", flag1, param2, position); DICMDBUF0 = 0xD1000000 | ((flag1 & 1) << 16) | param2; DICMDBUF1 = position & 0xFFFFFF; DICMDBUF2 = 0; return StartImmediateTransfer(request); } case DIIoctl::DVDLowStopLaser: - INFO_LOG(IOS_DI, "DVDLowStopLaser"); + INFO_LOG_FMT(IOS_DI, "DVDLowStopLaser"); DICMDBUF0 = 0xD2000000; return StartImmediateTransfer(request); case DIIoctl::DVDLowOffset: { const u8 flag = Memory::Read_U8(request.buffer_in + 7); const u32 offset = Memory::Read_U32(request.buffer_in + 8); - INFO_LOG(IOS_DI, "DVDLowOffset(%d): offset 0x%08x", flag, offset); + INFO_LOG_FMT(IOS_DI, "DVDLowOffset({}): offset {:#010x}", flag, offset); DICMDBUF0 = 0xD9000000 | ((flag & 1) << 16); DICMDBUF1 = offset; return StartImmediateTransfer(request); } case DIIoctl::DVDLowReadDiskBca: - INFO_LOG(IOS_DI, "DVDLowReadDiskBca"); + INFO_LOG_FMT(IOS_DI, "DVDLowReadDiskBca"); DICMDBUF0 = 0xDA000000; return StartDMATransfer(0x40, request); case DIIoctl::DVDLowRequestDiscStatus: - INFO_LOG(IOS_DI, "DVDLowRequestDiscStatus"); + INFO_LOG_FMT(IOS_DI, "DVDLowRequestDiscStatus"); DICMDBUF0 = 0xDB000000; return StartImmediateTransfer(request); case DIIoctl::DVDLowRequestRetryNumber: - INFO_LOG(IOS_DI, "DVDLowRequestRetryNumber"); + INFO_LOG_FMT(IOS_DI, "DVDLowRequestRetryNumber"); DICMDBUF0 = 0xDC000000; return StartImmediateTransfer(request); case DIIoctl::DVDLowSetMaximumRotation: { const u8 speed = Memory::Read_U8(request.buffer_in + 7); - INFO_LOG(IOS_DI, "DVDLowSetMaximumRotation: speed %d", speed); + INFO_LOG_FMT(IOS_DI, "DVDLowSetMaximumRotation: speed {}", speed); DICMDBUF0 = 0xDD000000 | ((speed & 3) << 16); return StartImmediateTransfer(request, false); } @@ -425,12 +425,12 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) { const u8 flag1 = Memory::Read_U8(request.buffer_in + 7); const u8 flag2 = Memory::Read_U8(request.buffer_in + 11); - INFO_LOG(IOS_DI, "DVDLowSerMeasControl(%d, %d)", flag1, flag2); + INFO_LOG_FMT(IOS_DI, "DVDLowSerMeasControl({}, {})", flag1, flag2); DICMDBUF0 = 0xDF000000 | ((flag1 & 1) << 17) | ((flag2 & 1) << 16); return StartDMATransfer(0x20, request); } case DIIoctl::DVDLowRequestError: - INFO_LOG(IOS_DI, "DVDLowRequestError"); + INFO_LOG_FMT(IOS_DI, "DVDLowRequestError"); DICMDBUF0 = 0xE0000000; return StartImmediateTransfer(request); case DIIoctl::DVDLowAudioStream: @@ -438,8 +438,8 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) const u8 mode = Memory::Read_U8(request.buffer_in + 7); const u32 length = Memory::Read_U32(request.buffer_in + 8); const u32 position = Memory::Read_U32(request.buffer_in + 12); - INFO_LOG(IOS_DI, "DVDLowAudioStream(%d): offset 0x%08x (byte 0x%09" PRIx64 "), length 0x%x", - mode, position, static_cast(position) << 2, length); + INFO_LOG_FMT(IOS_DI, "DVDLowAudioStream({}): offset {:#010x} (byte {:#011x}), length {:#x}", + mode, position, static_cast(position) << 2, length); DICMDBUF0 = 0xE1000000 | ((mode & 3) << 16); DICMDBUF1 = position; DICMDBUF2 = length; @@ -448,7 +448,7 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) case DIIoctl::DVDLowRequestAudioStatus: { const u8 mode = Memory::Read_U8(request.buffer_in + 7); - INFO_LOG(IOS_DI, "DVDLowRequestAudioStatus(%d)", mode); + INFO_LOG_FMT(IOS_DI, "DVDLowRequestAudioStatus({})", mode); DICMDBUF0 = 0xE2000000 | ((mode & 3) << 16); DICMDBUF1 = 0; // Note that this command does not copy the value written to DIIMMBUF, which makes it rather @@ -459,7 +459,7 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) { const u8 eject = Memory::Read_U8(request.buffer_in + 7); const u8 kill = Memory::Read_U8(request.buffer_in + 11); - INFO_LOG(IOS_DI, "DVDLowStopMotor(%d, %d)", eject, kill); + INFO_LOG_FMT(IOS_DI, "DVDLowStopMotor({}, {})", eject, kill); DICMDBUF0 = 0xE3000000 | ((eject & 1) << 17) | ((kill & 1) << 20); DICMDBUF1 = 0; return StartImmediateTransfer(request); @@ -468,8 +468,8 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) { const u8 enable = Memory::Read_U8(request.buffer_in + 7); const u8 buffer_size = Memory::Read_U8(request.buffer_in + 11); - INFO_LOG(IOS_DI, "DVDLowAudioBufferConfig: %s, buffer size %d", enable ? "enabled" : "disabled", - buffer_size); + INFO_LOG_FMT(IOS_DI, "DVDLowAudioBufferConfig: {}, buffer size {}", + enable ? "enabled" : "disabled", buffer_size); DICMDBUF0 = 0xE4000000 | ((enable & 1) << 16) | (buffer_size & 0xf); DICMDBUF1 = 0; // On the other hand, this command *does* copy DIIMMBUF, but the actual code in the drive never @@ -477,7 +477,7 @@ std::optional DI::StartIOCtl(const IOCtlRequest& request) return StartImmediateTransfer(request); } default: - ERROR_LOG(IOS_DI, "Unknown ioctl 0x%02x", request.request); + ERROR_LOG_FMT(IOS_DI, "Unknown ioctl {:#04x}", request.request); return DIResult::SecurityError; } } @@ -489,10 +489,11 @@ std::optional DI::StartDMATransfer(u32 command_length, const IOCtl // Actual /dev/di will still send a command, but won't write the length or output address, // causing it to eventually time out after 15 seconds. Just immediately time out here, // instead. - WARN_LOG(IOS_DI, - "Output buffer is too small for the result of the command (%d bytes given, needed at " - "least %d); returning read timed out (immediately, instead of waiting)", - request.buffer_out_size, command_length); + WARN_LOG_FMT( + IOS_DI, + "Output buffer is too small for the result of the command ({} bytes given, needed at " + "least {}); returning read timed out (immediately, instead of waiting)", + request.buffer_out_size, command_length); return DIResult::ReadTimedOut; } @@ -500,10 +501,11 @@ std::optional DI::StartDMATransfer(u32 command_length, const IOCtl { // In most cases, the actual DI driver just hangs for unaligned data, but let's be a bit more // gentle. - WARN_LOG(IOS_DI, - "Output buffer or length is incorrectly aligned (buffer 0x%08x, buffer length %x, " - "command length %x)", - request.buffer_out, request.buffer_out_size, command_length); + WARN_LOG_FMT( + IOS_DI, + "Output buffer or length is incorrectly aligned (buffer {:#010x}, buffer length {:x}, " + "command length {:x})", + request.buffer_out, request.buffer_out_size, command_length); return DIResult::BadArgument; } @@ -520,10 +522,11 @@ std::optional DI::StartImmediateTransfer(const IOCtlRequest& reque { if (write_to_buf && request.buffer_out_size < 4) { - WARN_LOG(IOS_DI, - "Output buffer size is too small for an immediate transfer (%d bytes, should be at " - "least 4). Performing transfer anyways.", - request.buffer_out_size); + WARN_LOG_FMT( + IOS_DI, + "Output buffer size is too small for an immediate transfer ({} bytes, should be at " + "least 4). Performing transfer anyways.", + request.buffer_out_size); } m_executing_command->m_copy_diimmbuf = write_to_buf; @@ -555,8 +558,8 @@ void DI::InterruptFromDVDInterface(DVDInterface::DIInterruptType interrupt_type) result = DIResult::DriveError; break; default: - PanicAlert("IOS::HLE::Device::DI: Unexpected DVDInterface interrupt %d!", - static_cast(interrupt_type)); + PanicAlertFmt("IOS::HLE::Device::DI: Unexpected DVDInterface interrupt {0}!", + static_cast(interrupt_type)); result = DIResult::DriveError; break; } @@ -568,8 +571,8 @@ void DI::InterruptFromDVDInterface(DVDInterface::DIInterruptType interrupt_type) } else { - PanicAlert("IOS::HLE::Device::DI: Received interrupt from DVDInterface when device wasn't " - "registered!"); + PanicAlertFmt("IOS::HLE::Device::DI: Received interrupt from DVDInterface when device wasn't " + "registered!"); } } @@ -581,14 +584,15 @@ void DI::FinishDICommandCallback(u64 userdata, s64 ticksbehind) if (di) di->FinishDICommand(result); else - PanicAlert("IOS::HLE::Device::DI: Received interrupt from DI when device wasn't registered!"); + PanicAlertFmt( + "IOS::HLE::Device::DI: Received interrupt from DI when device wasn't registered!"); } void DI::FinishDICommand(DIResult result) { if (!m_executing_command.has_value()) { - PanicAlert("IOS::HLE::Device::DI: There is no command to finish!"); + PanicAlertFmt("IOS::HLE::Device::DI: There is no command to finish!"); return; } @@ -617,17 +621,18 @@ IPCCommandResult DI::IOCtlV(const IOCtlVRequest& request) if (request.in_vectors[0].size != 0x20) { - ERROR_LOG(IOS_DI, "IOCtlV: Received bad input buffer size 0x%02x, should be 0x20", - request.in_vectors[0].size); + ERROR_LOG_FMT(IOS_DI, "IOCtlV: Received bad input buffer size {:#04x}, should be 0x20", + request.in_vectors[0].size); return GetDefaultReply(static_cast(DIResult::BadArgument)); } const u8 command = Memory::Read_U8(request.in_vectors[0].address); if (request.request != command) { - WARN_LOG(IOS_DI, - "IOCtlV: Received conflicting commands: ioctl 0x%02x, buffer 0x%02x. Using ioctlv " - "command.", - request.request, command); + WARN_LOG_FMT( + IOS_DI, + "IOCtlV: Received conflicting commands: ioctl {:#04x}, buffer {:#04x}. Using ioctlv " + "command.", + request.request, command); } DIResult return_value = DIResult::BadArgument; @@ -637,20 +642,21 @@ IPCCommandResult DI::IOCtlV(const IOCtlVRequest& request) { if (request.in_vectors.size() != 3 || request.io_vectors.size() != 2) { - ERROR_LOG(IOS_DI, "DVDLowOpenPartition: bad vector count %zu in/%zu out", - request.in_vectors.size(), request.io_vectors.size()); + ERROR_LOG_FMT(IOS_DI, "DVDLowOpenPartition: bad vector count {} in/{} out", + request.in_vectors.size(), request.io_vectors.size()); break; } if (request.in_vectors[1].address != 0) { - ERROR_LOG(IOS_DI, - "DVDLowOpenPartition with ticket - not implemented, ignoring ticket parameter"); + ERROR_LOG_FMT(IOS_DI, + "DVDLowOpenPartition with ticket - not implemented, ignoring ticket parameter"); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DIFFERENT_PARTITION_COMMAND); } if (request.in_vectors[2].address != 0) { - ERROR_LOG(IOS_DI, - "DVDLowOpenPartition with cert chain - not implemented, ignoring certs parameter"); + ERROR_LOG_FMT( + IOS_DI, + "DVDLowOpenPartition with cert chain - not implemented, ignoring certs parameter"); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DIFFERENT_PARTITION_COMMAND); } @@ -658,7 +664,7 @@ IPCCommandResult DI::IOCtlV(const IOCtlVRequest& request) static_cast(Memory::Read_U32(request.in_vectors[0].address + 4)) << 2; ChangePartition(DiscIO::Partition(partition_offset)); - INFO_LOG(IOS_DI, "DVDLowOpenPartition: partition_offset 0x%09" PRIx64, partition_offset); + INFO_LOG_FMT(IOS_DI, "DVDLowOpenPartition: partition_offset {:#011x}", partition_offset); // Read TMD to the buffer const IOS::ES::TMDReader tmd = DVDThread::GetTMD(m_current_partition); @@ -672,30 +678,30 @@ IPCCommandResult DI::IOCtlV(const IOCtlVRequest& request) break; } case DIIoctl::DVDLowGetNoDiscOpenPartitionParams: - ERROR_LOG(IOS_DI, "DVDLowGetNoDiscOpenPartitionParams - dummied out"); + ERROR_LOG_FMT(IOS_DI, "DVDLowGetNoDiscOpenPartitionParams - dummied out"); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DIFFERENT_PARTITION_COMMAND); request.DumpUnknown(GetDeviceName(), Common::Log::IOS_DI); break; case DIIoctl::DVDLowNoDiscOpenPartition: - ERROR_LOG(IOS_DI, "DVDLowNoDiscOpenPartition - dummied out"); + ERROR_LOG_FMT(IOS_DI, "DVDLowNoDiscOpenPartition - dummied out"); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DIFFERENT_PARTITION_COMMAND); request.DumpUnknown(GetDeviceName(), Common::Log::IOS_DI); break; case DIIoctl::DVDLowGetNoDiscBufferSizes: - ERROR_LOG(IOS_DI, "DVDLowGetNoDiscBufferSizes - dummied out"); + ERROR_LOG_FMT(IOS_DI, "DVDLowGetNoDiscBufferSizes - dummied out"); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DIFFERENT_PARTITION_COMMAND); request.DumpUnknown(GetDeviceName(), Common::Log::IOS_DI); break; case DIIoctl::DVDLowOpenPartitionWithTmdAndTicket: - ERROR_LOG(IOS_DI, "DVDLowOpenPartitionWithTmdAndTicket - not implemented"); + ERROR_LOG_FMT(IOS_DI, "DVDLowOpenPartitionWithTmdAndTicket - not implemented"); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DIFFERENT_PARTITION_COMMAND); break; case DIIoctl::DVDLowOpenPartitionWithTmdAndTicketView: - ERROR_LOG(IOS_DI, "DVDLowOpenPartitionWithTmdAndTicketView - not implemented"); + ERROR_LOG_FMT(IOS_DI, "DVDLowOpenPartitionWithTmdAndTicketView - not implemented"); DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_DIFFERENT_PARTITION_COMMAND); break; default: - ERROR_LOG(IOS_DI, "Unknown ioctlv 0x%02x", request.request); + ERROR_LOG_FMT(IOS_DI, "Unknown ioctlv {:#04x}", request.request); request.DumpUnknown(GetDeviceName(), Common::Log::IOS_DI); } return GetDefaultReply(static_cast(return_value)); diff --git a/Source/Core/Core/IOS/Device.cpp b/Source/Core/Core/IOS/Device.cpp index bd99d0ffdd..b3324503f0 100644 --- a/Source/Core/Core/IOS/Device.cpp +++ b/Source/Core/Core/IOS/Device.cpp @@ -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 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 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); } diff --git a/Source/Core/Core/IOS/Device.h b/Source/Core/Core/IOS/Device.h index 5b96de41a6..bffe1cdc1c 100644 --- a/Source/Core/Core/IOS/Device.h +++ b/Source/Core/Core/IOS/Device.h @@ -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; diff --git a/Source/Core/Core/IOS/DeviceStub.cpp b/Source/Core/Core/IOS/DeviceStub.cpp index 10ddffa150..abef404392 100644 --- a/Source/Core/Core/IOS/DeviceStub.cpp +++ b/Source/Core/Core/IOS/DeviceStub.cpp @@ -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 diff --git a/Source/Core/Core/IOS/ES/ES.cpp b/Source/Core/Core/IOS/ES/ES.cpp index 0f24d34785..7578159403 100644 --- a/Source/Core/Core/IOS/ES/ES.cpp +++ b/Source/Core/Core/IOS/ES/ES.cpp @@ -5,7 +5,6 @@ #include "Core/IOS/ES/ES.h" #include -#include #include #include #include @@ -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(Memory::GetPointer(request.io_vectors[0].address)); + sprintf(path, "/title/%08x/%08x/data", static_cast(title_id >> 32), + static_cast(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(title_id >> 32), - static_cast(title_id)); + INFO_LOG_FMT(IOS_ES, "IOCTL_ES_GETTITLEID: {:08x}/{:08x}", static_cast(title_id >> 32), + static_cast(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,7 +960,7 @@ 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; } @@ -963,11 +968,14 @@ ReturnCode ES::VerifyContainer(VerifyContainerType type, VerifyMode mode, { 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) diff --git a/Source/Core/Core/IOS/ES/Formats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp index 6e9a31f55c..cbfb926918 100644 --- a/Source/Core/Core/IOS/ES/Formats.cpp +++ b/Source/Core/Core/IOS/ES/Formats.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -430,8 +429,8 @@ std::array 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; } diff --git a/Source/Core/Core/IOS/ES/Identity.cpp b/Source/Core/Core/IOS/ES/Identity.cpp index 1635202876..b89b932184 100644 --- a/Source/Core/Core/IOS/ES/Identity.cpp +++ b/Source/Core/Core/IOS/ES/Identity.cpp @@ -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& hash, const std::vector& 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& hash, const std::vector& 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& hash, const std::vector& 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; } diff --git a/Source/Core/Core/IOS/ES/NandUtils.cpp b/Source/Core/Core/IOS/ES/NandUtils.cpp index ab25f06c76..6ff03bb89e 100644 --- a/Source/Core/Core/IOS/ES/NandUtils.cpp +++ b/Source/Core/Core/IOS/ES/NandUtils.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -75,7 +74,7 @@ static std::vector 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 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,7 +241,7 @@ 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; } @@ -250,7 +249,7 @@ bool ES::CreateTitleDirectories(u64 title_id, u16 group_id) const 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; diff --git a/Source/Core/Core/IOS/ES/TitleContents.cpp b/Source/Core/Core/IOS/ES/TitleContents.cpp index 598f177192..cf89033a61 100644 --- a/Source/Core/Core/IOS/ES/TitleContents.cpp +++ b/Source/Core/Core/IOS/ES/TitleContents.cpp @@ -4,7 +4,6 @@ #include "Core/IOS/ES/ES.h" -#include #include #include @@ -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(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; } diff --git a/Source/Core/Core/IOS/ES/TitleInformation.cpp b/Source/Core/Core/IOS/ES/TitleInformation.cpp index cb6451d9c3..1cd9413d24 100644 --- a/Source/Core/Core/IOS/ES/TitleInformation.cpp +++ b/Source/Core/Core/IOS/ES/TitleInformation.cpp @@ -4,7 +4,6 @@ #include "Core/IOS/ES/ES.h" -#include #include #include #include @@ -26,8 +25,8 @@ IPCCommandResult ES::GetStoredContentsCount(const IOS::ES::TMDReader& tmd, const u16 num_contents = static_cast(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,7 +128,7 @@ IPCCommandResult ES::GetTitles(const std::vector& 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(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); } @@ -137,7 +136,7 @@ IPCCommandResult ES::GetTitles(const std::vector& titles, const IOCtlVReque IPCCommandResult ES::GetTitleCount(const IOCtlVRequest& request) { const std::vector 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(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 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(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 diff --git a/Source/Core/Core/IOS/ES/TitleManagement.cpp b/Source/Core/Core/IOS/ES/TitleManagement.cpp index 21d4b6cdbd..8669491f48 100644 --- a/Source/Core/Core/IOS/ES/TitleManagement.cpp +++ b/Source/Core/Core/IOS/ES/TitleManagement.cpp @@ -63,14 +63,15 @@ ReturnCode ES::ImportTicket(const std::vector& 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& 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& 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,13 +156,13 @@ ReturnCode ES::ImportTmd(Context& context, const std::vector& 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; } @@ -169,11 +170,11 @@ ReturnCode ES::ImportTmd(Context& context, const std::vector& tmd_bytes) 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& ticket_bytes, IOSC& ReturnCode ES::ImportTitleInit(Context& context, const std::vector& tmd_bytes, const std::vector& 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; } diff --git a/Source/Core/Core/IOS/ES/Views.cpp b/Source/Core/Core/IOS/ES/Views.cpp index e62df37e6b..9e800af971 100644 --- a/Source/Core/Core/IOS/ES/Views.cpp +++ b/Source/Core/Core/IOS/ES/Views.cpp @@ -5,7 +5,6 @@ #include "Core/IOS/ES/ES.h" #include -#include #include #include #include @@ -43,7 +42,7 @@ 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(ticket.GetNumberOfTickets()) : 0; @@ -51,16 +50,16 @@ IPCCommandResult ES::GetTicketViewCount(const IOCtlVRequest& request) 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(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); } diff --git a/Source/Core/Core/IOS/IOS.cpp b/Source/Core/Core/IOS/IOS.cpp index b5fe88b709..469d98386a 100644 --- a/Source/Core/Core/IOS/IOS.cpp +++ b/Source/Core/Core/IOS/IOS.cpp @@ -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 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,7 +690,7 @@ 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; } @@ -698,7 +698,7 @@ void Kernel::UpdateIPC() 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; } diff --git a/Source/Core/Core/IOS/IOSC.cpp b/Source/Core/Core/IOS/IOSC.cpp index 9b70e70e95..d80bcb6f1a 100644 --- a/Source/Core/Core/IOS/IOSC.cpp +++ b/Source/Core/Core/IOS/IOSC.cpp @@ -328,7 +328,7 @@ ReturnCode IOSC::VerifyPublicKeySign(const std::array& sha1, Handle sign MBEDTLS_MD_SHA1, 0, sha1.data(), signature.data()); if (ret != 0) { - WARN_LOG(IOS, "VerifyPublicKeySign: RSA verification failed (error %d)", ret); + WARN_LOG_FMT(IOS, "VerifyPublicKeySign: RSA verification failed (error {})", ret); return IOSC_FAIL_CHECKVALUE; } @@ -561,14 +561,14 @@ void IOSC::LoadEntries() File::IOFile file{File::GetUserPath(D_WIIROOT_IDX) + "/keys.bin", "rb"}; if (!file) { - WARN_LOG(IOS, "keys.bin could not be found. Default values will be used."); + WARN_LOG_FMT(IOS, "keys.bin could not be found. Default values will be used."); return; } BootMiiKeyDump dump; if (!file.ReadBytes(&dump, sizeof(dump))) { - ERROR_LOG(IOS, "Failed to read from keys.bin."); + ERROR_LOG_FMT(IOS, "Failed to read from keys.bin."); return; } diff --git a/Source/Core/Core/IOS/MIOS.cpp b/Source/Core/Core/IOS/MIOS.cpp index 901ffe6711..3be52ed411 100644 --- a/Source/Core/Core/IOS/MIOS.cpp +++ b/Source/Core/Core/IOS/MIOS.cpp @@ -55,7 +55,7 @@ bool Load() Memory::Write_U32(0x09142001, 0x3180); ReinitHardware(); - NOTICE_LOG(IOS, "Reinitialised hardware."); + NOTICE_LOG_FMT(IOS, "Reinitialised hardware."); // Load symbols for the IPL if they exist. if (!g_symbolDB.IsEmpty()) @@ -74,7 +74,7 @@ bool Load() PowerPC::SetMode(PowerPC::CoreMode::Interpreter); MSR.Hex = 0; PC = 0x3400; - NOTICE_LOG(IOS, "Loaded MIOS and bootstrapped PPC."); + NOTICE_LOG_FMT(IOS, "Loaded MIOS and bootstrapped PPC."); // IOS writes 0 to 0x30f8 before bootstrapping the PPC. Once started, the IPL eventually writes // 0xdeadbeef there, then waits for it to be cleared by IOS before continuing. @@ -83,7 +83,7 @@ bool Load() PowerPC::SetMode(core_mode); Memory::Write_U32(0x00000000, ADDRESS_INIT_SEMAPHORE); - NOTICE_LOG(IOS, "IPL ready."); + NOTICE_LOG_FMT(IOS, "IPL ready."); SConfig::GetInstance().m_is_mios = true; DVDInterface::UpdateRunningGameMetadata(); return true;