mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Merge pull request #9265 from lioncash/core-log3
Core: Convert logging over to fmt pt.3
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<std::mutex> 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<u16>(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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ MemoryCard::MemoryCard(const std::string& filename, int card_index, u16 size_mbi
|
||||
m_memcard_data = std::make_unique<u8[]>(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
|
||||
|
||||
@@ -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<u8> 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<u8> request_copy(s_si_buffer.data(), s_si_buffer.data() + request_length);
|
||||
|
||||
std::unique_ptr<ISIDevice>& device = s_channel[s_com_csr.CHANNEL].device;
|
||||
u32 actual_response_length = device->RunBuffer(s_si_buffer.data(), request_length);
|
||||
const std::unique_ptr<ISIDevice>& 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:
|
||||
|
||||
@@ -66,8 +66,8 @@ SIDevices ISIDevice::GetDeviceType() const
|
||||
int ISIDevice::RunBuffer(u8* buffer, int request_length)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
DEBUG_LOG(SERIALINTERFACE, "Send Data Device(%i) - Length(%i) ", m_device_number,
|
||||
request_length);
|
||||
DEBUG_LOG_FMT(SERIALINTERFACE, "Send Data Device({}) - Length({}) ", m_device_number,
|
||||
request_length);
|
||||
|
||||
std::string temp;
|
||||
int num = 0;
|
||||
@@ -79,12 +79,12 @@ int ISIDevice::RunBuffer(u8* buffer, int request_length)
|
||||
|
||||
if ((num % 8) == 0)
|
||||
{
|
||||
DEBUG_LOG(SERIALINTERFACE, "%s", temp.c_str());
|
||||
DEBUG_LOG_FMT(SERIALINTERFACE, "{}", temp);
|
||||
temp.clear();
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_LOG(SERIALINTERFACE, "%s", temp.c_str());
|
||||
DEBUG_LOG_FMT(SERIALINTERFACE, "{}", temp);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -300,8 +300,8 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int request_length)
|
||||
if (m_sock_server.Connect())
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
NOTICE_LOG(SERIALINTERFACE, "%01d cmd %02x [> %02x%02x%02x%02x]", m_device_number, buffer[0],
|
||||
buffer[1], buffer[2], buffer[3], buffer[4]);
|
||||
NOTICE_LOG_FMT(SERIALINTERFACE, "{} cmd {:02x} [> {:02x}{:02x}{:02x}{:02x}]", m_device_number,
|
||||
buffer[0], buffer[1], buffer[2], buffer[3], buffer[4]);
|
||||
#endif
|
||||
m_sock_server.Send(buffer);
|
||||
}
|
||||
@@ -341,16 +341,17 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int request_length)
|
||||
const Common::Log::LOG_LEVELS log_level =
|
||||
(m_last_cmd == CMD_STATUS || m_last_cmd == CMD_RESET) ? Common::Log::LERROR :
|
||||
Common::Log::LWARNING;
|
||||
GENERIC_LOG(Common::Log::SERIALINTERFACE, log_level,
|
||||
"%01d [< %02x%02x%02x%02x%02x] (%i)", m_device_number,
|
||||
buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], num_data_received);
|
||||
GENERIC_LOG_FMT(Common::Log::SERIALINTERFACE, log_level,
|
||||
"{} [< {:02x}{:02x}{:02x}{:02x}{:02x}] ({})",
|
||||
m_device_number, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4],
|
||||
num_data_received);
|
||||
#endif
|
||||
return num_data_received;
|
||||
}
|
||||
}
|
||||
|
||||
// This should never happen, but appease MSVC which thinks it might.
|
||||
ERROR_LOG(SERIALINTERFACE, "Unknown state %i\n", static_cast<int>(m_next_action));
|
||||
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown state {}\n", m_next_action);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
|
||||
|
||||
case CMD_DIRECT:
|
||||
{
|
||||
INFO_LOG(SERIALINTERFACE, "PAD - Direct (Request length: %d)", request_length);
|
||||
INFO_LOG_FMT(SERIALINTERFACE, "PAD - Direct (Request length: {})", request_length);
|
||||
u32 high, low;
|
||||
GetData(high, low);
|
||||
for (int i = 0; i < 4; i++)
|
||||
@@ -78,7 +78,7 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
|
||||
|
||||
case CMD_ORIGIN:
|
||||
{
|
||||
INFO_LOG(SERIALINTERFACE, "PAD - Get Origin");
|
||||
INFO_LOG_FMT(SERIALINTERFACE, "PAD - Get Origin");
|
||||
|
||||
u8* calibration = reinterpret_cast<u8*>(&m_origin);
|
||||
for (int i = 0; i < (int)sizeof(SOrigin); i++)
|
||||
@@ -91,7 +91,7 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
|
||||
// Recalibrate (FiRES: i am not 100 percent sure about this)
|
||||
case CMD_RECALIBRATE:
|
||||
{
|
||||
INFO_LOG(SERIALINTERFACE, "PAD - Recalibrate");
|
||||
INFO_LOG_FMT(SERIALINTERFACE, "PAD - Recalibrate");
|
||||
|
||||
u8* calibration = reinterpret_cast<u8*>(&m_origin);
|
||||
for (int i = 0; i < (int)sizeof(SOrigin); i++)
|
||||
@@ -104,8 +104,8 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
|
||||
// DEFAULT
|
||||
default:
|
||||
{
|
||||
ERROR_LOG(SERIALINTERFACE, "Unknown SI command (0x%x)", command);
|
||||
PanicAlert("SI: Unknown command (0x%x)", command);
|
||||
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown SI command ({:#x})", command);
|
||||
PanicAlertFmt("SI: Unknown command ({:#x})", command);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -263,12 +263,12 @@ CSIDevice_GCController::HandleButtonCombos(const GCPadStatus& pad_status)
|
||||
{
|
||||
if (m_last_button_combo == COMBO_RESET)
|
||||
{
|
||||
INFO_LOG(SERIALINTERFACE, "PAD - COMBO_RESET");
|
||||
INFO_LOG_FMT(SERIALINTERFACE, "PAD - COMBO_RESET");
|
||||
ProcessorInterface::ResetButton_Tap();
|
||||
}
|
||||
else if (m_last_button_combo == COMBO_ORIGIN)
|
||||
{
|
||||
INFO_LOG(SERIALINTERFACE, "PAD - COMBO_ORIGIN");
|
||||
INFO_LOG_FMT(SERIALINTERFACE, "PAD - COMBO_ORIGIN");
|
||||
SetOrigin(pad_status);
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ void CSIDevice_GCController::SendCommand(u32 command, u8 poll)
|
||||
|
||||
case CMD_WRITE:
|
||||
{
|
||||
unsigned int type = controller_command.parameter1; // 0 = stop, 1 = rumble, 2 = stop hard
|
||||
const u32 type = controller_command.parameter1; // 0 = stop, 1 = rumble, 2 = stop hard
|
||||
|
||||
// get the correct pad number that should rumble locally when using netplay
|
||||
const int pad_num = NetPlay_InGamePadToLocalPad(m_device_number);
|
||||
@@ -316,18 +316,18 @@ void CSIDevice_GCController::SendCommand(u32 command, u8 poll)
|
||||
CSIDevice_GCController::Rumble(pad_num, 0.0);
|
||||
}
|
||||
|
||||
if (!poll)
|
||||
if (poll == 0)
|
||||
{
|
||||
m_mode = controller_command.parameter2;
|
||||
INFO_LOG(SERIALINTERFACE, "PAD %i set to mode %i", m_device_number, m_mode);
|
||||
INFO_LOG_FMT(SERIALINTERFACE, "PAD {} set to mode {}", m_device_number, m_mode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
ERROR_LOG(SERIALINTERFACE, "Unknown direct command (0x%x)", command);
|
||||
PanicAlert("SI: Unknown direct command");
|
||||
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown direct command ({:#x})", command);
|
||||
PanicAlertFmt("SI: Unknown direct command");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -129,15 +129,15 @@ void CSIDevice_GCSteeringWheel::SendCommand(u32 command, u8 poll)
|
||||
Pad::Rumble(pad_num, 0);
|
||||
break;
|
||||
default:
|
||||
WARN_LOG(SERIALINTERFACE, "Unknown CMD_FORCE type %i", int(type));
|
||||
WARN_LOG_FMT(SERIALINTERFACE, "Unknown CMD_FORCE type {}", int(type));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!poll)
|
||||
if (poll == 0)
|
||||
{
|
||||
m_mode = wheel_command.parameter2;
|
||||
INFO_LOG(SERIALINTERFACE, "PAD %i set to mode %i", m_device_number, m_mode);
|
||||
INFO_LOG_FMT(SERIALINTERFACE, "PAD {} set to mode {}", m_device_number, m_mode);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -27,7 +27,7 @@ int CSIDevice_Keyboard::RunBuffer(u8* buffer, int request_length)
|
||||
ISIDevice::RunBuffer(buffer, request_length);
|
||||
|
||||
// Read the command
|
||||
EBufferCommands command = static_cast<EBufferCommands>(buffer[0]);
|
||||
const auto command = static_cast<EBufferCommands>(buffer[0]);
|
||||
|
||||
// Handle it
|
||||
switch (command)
|
||||
@@ -42,7 +42,7 @@ int CSIDevice_Keyboard::RunBuffer(u8* buffer, int request_length)
|
||||
|
||||
case CMD_DIRECT:
|
||||
{
|
||||
INFO_LOG(SERIALINTERFACE, "Keyboard - Direct (Request Length: %d)", request_length);
|
||||
INFO_LOG_FMT(SERIALINTERFACE, "Keyboard - Direct (Request Length: {})", request_length);
|
||||
u32 high, low;
|
||||
GetData(high, low);
|
||||
for (int i = 0; i < 4; i++)
|
||||
@@ -55,7 +55,7 @@ int CSIDevice_Keyboard::RunBuffer(u8* buffer, int request_length)
|
||||
|
||||
default:
|
||||
{
|
||||
ERROR_LOG(SERIALINTERFACE, "Unknown SI command (0x%x)", command);
|
||||
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown SI command ({:#x})", command);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ void CSIDevice_Keyboard::SendCommand(u32 command, u8 poll)
|
||||
break;
|
||||
default:
|
||||
{
|
||||
ERROR_LOG(SERIALINTERFACE, "Unknown direct command (0x%x)", command);
|
||||
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown direct command ({:#x})", command);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ void Wiimote::HandleReportMode(const OutputReportMode& dr)
|
||||
if (!DataReportBuilder::IsValidMode(dr.mode))
|
||||
{
|
||||
// A real wiimote ignores the entire message if the mode is invalid.
|
||||
WARN_LOG(WIIMOTE, "Game requested invalid report mode: 0x%02x", int(dr.mode));
|
||||
WARN_LOG_FMT(WIIMOTE, "Game requested invalid report mode: {:#04x}", dr.mode);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ void Wiimote::InvokeHandler(H&& handler, const WiimoteCommon::OutputReportGeneri
|
||||
{
|
||||
if (size < sizeof(T))
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "InvokeHandler: report: 0x%02x invalid size: %d", int(rpt.rpt_id), size);
|
||||
ERROR_LOG_FMT(WIIMOTE, "InvokeHandler: report: {:#04x} invalid size: {}", rpt.rpt_id, size);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,18 +75,18 @@ void Wiimote::EventUnlinked()
|
||||
|
||||
void Wiimote::InterruptDataOutput(const u8* data, u32 size)
|
||||
{
|
||||
if (!size)
|
||||
if (size == 0)
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "OutputData: zero sized data");
|
||||
ERROR_LOG_FMT(WIIMOTE, "OutputData: zero sized data");
|
||||
return;
|
||||
}
|
||||
|
||||
auto& rpt = *reinterpret_cast<const OutputReportGeneric*>(data);
|
||||
const auto& rpt = *reinterpret_cast<const OutputReportGeneric*>(data);
|
||||
const int rpt_size = size - OutputReportGeneric::HEADER_SIZE;
|
||||
|
||||
if (!rpt_size)
|
||||
if (rpt_size == 0)
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "OutputData: zero sized report");
|
||||
ERROR_LOG_FMT(WIIMOTE, "OutputData: zero sized report");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ void Wiimote::InterruptDataOutput(const u8* data, u32 size)
|
||||
InvokeHandler<OutputReportEnableFeature>(&Wiimote::HandleIRLogicEnable2, rpt, rpt_size);
|
||||
break;
|
||||
default:
|
||||
PanicAlert("HidOutputReport: Unknown report ID 0x%02x", int(rpt.rpt_id));
|
||||
PanicAlertFmt("HidOutputReport: Unknown report ID {:#04x}", rpt.rpt_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -255,17 +255,17 @@ void Wiimote::HandleWriteData(const OutputReportWriteData& wd)
|
||||
{
|
||||
// FYI: Writes during an active read will occasionally produce a "busy" (0x4) ack.
|
||||
// We won't simulate that as it often does work. Poorly programmed games may rely on it.
|
||||
WARN_LOG(WIIMOTE, "WriteData: write during active read request.");
|
||||
WARN_LOG_FMT(WIIMOTE, "WriteData: write during active read request.");
|
||||
}
|
||||
|
||||
u16 address = Common::swap16(wd.address);
|
||||
const u16 address = Common::swap16(wd.address);
|
||||
|
||||
DEBUG_LOG(WIIMOTE, "Wiimote::WriteData: 0x%02x @ 0x%02x @ 0x%02x (%d)", wd.space,
|
||||
wd.slave_address, address, wd.size);
|
||||
DEBUG_LOG_FMT(WIIMOTE, "Wiimote::WriteData: {:#04x} @ {:#04x} @ {:#04x} ({})", wd.space,
|
||||
wd.slave_address, address, wd.size);
|
||||
|
||||
if (0 == wd.size || wd.size > 16)
|
||||
{
|
||||
WARN_LOG(WIIMOTE, "WriteData: invalid size: %d", wd.size);
|
||||
WARN_LOG_FMT(WIIMOTE, "WriteData: invalid size: {}", wd.size);
|
||||
// A real wiimote silently ignores such a request:
|
||||
return;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ void Wiimote::HandleWriteData(const OutputReportWriteData& wd)
|
||||
{
|
||||
if (address + wd.size > EEPROM_FREE_SIZE)
|
||||
{
|
||||
WARN_LOG(WIIMOTE, "WriteData: address + size out of bounds!");
|
||||
WARN_LOG_FMT(WIIMOTE, "WriteData: address + size out of bounds!");
|
||||
error_code = ErrorCode::InvalidAddress;
|
||||
}
|
||||
else
|
||||
@@ -295,7 +295,7 @@ void Wiimote::HandleWriteData(const OutputReportWriteData& wd)
|
||||
// Attempting to access the EEPROM directly over i2c results in error 8.
|
||||
if (EEPROM_I2C_ADDR == m_read_request.slave_address)
|
||||
{
|
||||
WARN_LOG(WIIMOTE, "Attempt to write EEPROM directly.");
|
||||
WARN_LOG_FMT(WIIMOTE, "Attempt to write EEPROM directly.");
|
||||
error_code = ErrorCode::InvalidAddress;
|
||||
break;
|
||||
}
|
||||
@@ -311,7 +311,7 @@ void Wiimote::HandleWriteData(const OutputReportWriteData& wd)
|
||||
break;
|
||||
|
||||
default:
|
||||
WARN_LOG(WIIMOTE, "WriteData: invalid address space: 0x%x", wd.space);
|
||||
WARN_LOG_FMT(WIIMOTE, "WriteData: invalid address space: {:#x}", wd.space);
|
||||
// A real wiimote gives error 6:
|
||||
error_code = ErrorCode::InvalidSpace;
|
||||
break;
|
||||
@@ -383,7 +383,7 @@ void Wiimote::HandleSpeakerData(const WiimoteCommon::OutputReportSpeakerData& rp
|
||||
{
|
||||
if (rpt.length > std::size(rpt.data))
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "Bad speaker data length: %d", rpt.length);
|
||||
ERROR_LOG_FMT(WIIMOTE, "Bad speaker data length: {}", rpt.length);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -403,7 +403,7 @@ void Wiimote::HandleReadData(const OutputReportReadData& rd)
|
||||
if (m_read_request.size)
|
||||
{
|
||||
// There is already an active read being processed.
|
||||
WARN_LOG(WIIMOTE, "ReadData: attempting read during active request.");
|
||||
WARN_LOG_FMT(WIIMOTE, "ReadData: attempting read during active request.");
|
||||
|
||||
// A real wm+ sends a busy ack in this situation.
|
||||
SendAck(OutputReportID::ReadData, ErrorCode::Busy);
|
||||
@@ -417,8 +417,8 @@ void Wiimote::HandleReadData(const OutputReportReadData& rd)
|
||||
// A zero size request is just ignored, like on the real wiimote.
|
||||
m_read_request.size = Common::swap16(rd.size);
|
||||
|
||||
DEBUG_LOG(WIIMOTE, "Wiimote::ReadData: %d @ 0x%02x @ 0x%02x (%d)", int(m_read_request.space),
|
||||
m_read_request.slave_address, m_read_request.address, m_read_request.size);
|
||||
DEBUG_LOG_FMT(WIIMOTE, "Wiimote::ReadData: {} @ {:#04x} @ {:#04x} ({})", m_read_request.space,
|
||||
m_read_request.slave_address, m_read_request.address, m_read_request.size);
|
||||
|
||||
// Send up to one read-data-reply.
|
||||
// If more data needs to be sent it will happen on the next "Update()"
|
||||
@@ -480,7 +480,7 @@ bool Wiimote::ProcessReadDataRequest()
|
||||
// Attempting to access the EEPROM directly over i2c results in error 8.
|
||||
if (EEPROM_I2C_ADDR == m_read_request.slave_address)
|
||||
{
|
||||
WARN_LOG(WIIMOTE, "Attempt to read EEPROM directly.");
|
||||
WARN_LOG_FMT(WIIMOTE, "Attempt to read EEPROM directly.");
|
||||
error_code = ErrorCode::InvalidAddress;
|
||||
break;
|
||||
}
|
||||
@@ -504,8 +504,8 @@ bool Wiimote::ProcessReadDataRequest()
|
||||
|
||||
if (bytes_read != bytes_to_read)
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "Responding with read error 7 @ 0x%x @ 0x%x (%d)",
|
||||
m_read_request.slave_address, m_read_request.address, m_read_request.size);
|
||||
DEBUG_LOG_FMT(WIIMOTE, "Responding with read error 7 @ {:#x} @ {:#x} ({})",
|
||||
m_read_request.slave_address, m_read_request.address, m_read_request.size);
|
||||
error_code = ErrorCode::Nack;
|
||||
break;
|
||||
}
|
||||
@@ -515,7 +515,7 @@ bool Wiimote::ProcessReadDataRequest()
|
||||
break;
|
||||
|
||||
default:
|
||||
WARN_LOG(WIIMOTE, "ReadData: invalid address space: 0x%x", int(m_read_request.space));
|
||||
WARN_LOG_FMT(WIIMOTE, "ReadData: invalid address space: {:#x}", int(m_read_request.space));
|
||||
// A real wiimote gives error 6:
|
||||
error_code = ErrorCode::InvalidSpace;
|
||||
break;
|
||||
|
||||
@@ -501,7 +501,7 @@ EncryptionKey KeyGen::GenerateFromExtensionKeyData(const ExtKeyData& ext_key) co
|
||||
|
||||
// Retail games never hit this path but some homebrew fills encryption key with 0x00.
|
||||
// Real extensions seem to then use entirely differnet "sboxes" for table generation.
|
||||
WARN_LOG(WIIMOTE, "Extension key gen did not match any idx. Generating fallback tables.");
|
||||
WARN_LOG_FMT(WIIMOTE, "Extension key gen did not match any idx. Generating fallback tables.");
|
||||
return GenerateFallbackTables(rand, key);
|
||||
}
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ int MotionPlus::BusWrite(u8 slave_addr, u8 addr, int count, const u8* data_in)
|
||||
return m_i2c_bus.BusWrite(slave_addr, addr, count, data_in);
|
||||
}
|
||||
|
||||
DEBUG_LOG(WIIMOTE, "Inactive M+ write 0x%x : %s", addr, ArrayToString(data_in, count).c_str());
|
||||
DEBUG_LOG_FMT(WIIMOTE, "Inactive M+ write {:#x} : {}", addr, ArrayToString(data_in, count));
|
||||
|
||||
auto const result = RawWrite(&m_reg_data, addr, count, data_in);
|
||||
|
||||
@@ -255,7 +255,7 @@ int MotionPlus::BusWrite(u8 slave_addr, u8 addr, int count, const u8* data_in)
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEBUG_LOG(WIIMOTE, "Active M+ write 0x%x : %s", addr, ArrayToString(data_in, count).c_str());
|
||||
DEBUG_LOG_FMT(WIIMOTE, "Active M+ write {:#x} : {}", addr, ArrayToString(data_in, count));
|
||||
|
||||
auto const result = RawWrite(&m_reg_data, addr, count, data_in);
|
||||
|
||||
@@ -273,7 +273,7 @@ int MotionPlus::BusWrite(u8 slave_addr, u8 addr, int count, const u8* data_in)
|
||||
case offsetof(Register, challenge_type):
|
||||
if (ChallengeState::ParameterXReady == m_reg_data.challenge_state)
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "M+ challenge: 0x%x", m_reg_data.challenge_type);
|
||||
DEBUG_LOG_FMT(WIIMOTE, "M+ challenge: {:#x}", m_reg_data.challenge_type);
|
||||
|
||||
// After games read parameter x they write here to request y0 or y1.
|
||||
if (0 == m_reg_data.challenge_type)
|
||||
@@ -301,7 +301,7 @@ int MotionPlus::BusWrite(u8 slave_addr, u8 addr, int count, const u8* data_in)
|
||||
|
||||
case offsetof(Register, calibration_trigger):
|
||||
// Games seem to invoke this to start and stop calibration. Exact consequences unknown.
|
||||
DEBUG_LOG(WIIMOTE, "M+ calibration trigger: 0x%x", m_reg_data.calibration_trigger);
|
||||
DEBUG_LOG_FMT(WIIMOTE, "M+ calibration trigger: {:#x}", m_reg_data.calibration_trigger);
|
||||
break;
|
||||
|
||||
case PASSTHROUGH_MODE_OFFSET:
|
||||
@@ -343,7 +343,7 @@ void MotionPlus::OnPassthroughModeWrite()
|
||||
|
||||
void MotionPlus::Activate()
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "M+ has been activated.");
|
||||
DEBUG_LOG_FMT(WIIMOTE, "M+ has been activated.");
|
||||
|
||||
m_reg_data.ext_identifier[2] = ACTIVE_DEVICE_ADDR << 1;
|
||||
|
||||
@@ -360,7 +360,7 @@ void MotionPlus::Activate()
|
||||
|
||||
void MotionPlus::Deactivate()
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "M+ has been deactivated.");
|
||||
DEBUG_LOG_FMT(WIIMOTE, "M+ has been deactivated.");
|
||||
|
||||
m_reg_data.ext_identifier[2] = INACTIVE_DEVICE_ADDR << 1;
|
||||
|
||||
@@ -421,7 +421,7 @@ void MotionPlus::Update()
|
||||
{
|
||||
if (is_ext_connected)
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "M+ initializing new extension.");
|
||||
DEBUG_LOG_FMT(WIIMOTE, "M+ initializing new extension.");
|
||||
|
||||
// The M+ automatically initializes an extension when attached.
|
||||
|
||||
@@ -488,7 +488,7 @@ void MotionPlus::Update()
|
||||
// Big-int little endian parameter x.
|
||||
param_x.WriteLittleEndianBinary(&m_reg_data.challenge_data);
|
||||
|
||||
DEBUG_LOG(WIIMOTE, "M+ parameter x ready.");
|
||||
DEBUG_LOG_FMT(WIIMOTE, "M+ parameter x ready.");
|
||||
m_reg_data.challenge_state = ChallengeState::ParameterXReady;
|
||||
break;
|
||||
}
|
||||
@@ -514,7 +514,7 @@ void MotionPlus::Update()
|
||||
param_y1.WriteLittleEndianBinary(&m_reg_data.challenge_data);
|
||||
}
|
||||
|
||||
DEBUG_LOG(WIIMOTE, "M+ parameter y ready.");
|
||||
DEBUG_LOG_FMT(WIIMOTE, "M+ parameter y ready.");
|
||||
m_reg_data.challenge_state = ChallengeState::ParameterYReady;
|
||||
break;
|
||||
|
||||
@@ -583,7 +583,7 @@ void MotionPlus::PrepareInput(const Common::Vec3& angular_velocity)
|
||||
break;
|
||||
default:
|
||||
// This really shouldn't happen as the M+ deactivates on an invalid mode write.
|
||||
ERROR_LOG(WIIMOTE, "M+ unknown passthrough-mode %d", int(GetPassthroughMode()));
|
||||
ERROR_LOG_FMT(WIIMOTE, "M+ unknown passthrough-mode {}", GetPassthroughMode());
|
||||
mplus_data.is_mp_data = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -117,13 +117,13 @@ void SpeakerLogic::SpeakerData(const u8* data, int length, float speaker_pan)
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(IOS_WIIMOTE, "Unknown speaker format %x", reg_data.format);
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE, "Unknown speaker format {:x}", reg_data.format);
|
||||
return;
|
||||
}
|
||||
|
||||
if (reg_data.volume > volume_divisor)
|
||||
{
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Wiimote volume is higher than suspected maximum!");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Wiimote volume is higher than suspected maximum!");
|
||||
volume_divisor = reg_data.volume;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ void Wiimote::Reset()
|
||||
if (m_eeprom_dirty)
|
||||
{
|
||||
// Write out existing EEPROM
|
||||
INFO_LOG(WIIMOTE, "Wrote EEPROM for %s", GetName().c_str());
|
||||
INFO_LOG_FMT(WIIMOTE, "Wrote EEPROM for {}", GetName());
|
||||
std::ofstream file;
|
||||
File::OpenFStream(file, eeprom_file, std::ios::binary | std::ios::out);
|
||||
file.write(reinterpret_cast<char*>(m_eeprom.data.data()), EEPROM_FREE_SIZE);
|
||||
@@ -405,7 +405,7 @@ bool Wiimote::ProcessExtensionPortEvent()
|
||||
// FYI: This happens even during a read request which continues after the status report is sent.
|
||||
m_reporting_mode = InputReportID::ReportDisabled;
|
||||
|
||||
DEBUG_LOG(WIIMOTE, "Sending status report due to extension status change.");
|
||||
DEBUG_LOG_FMT(WIIMOTE, "Sending status report due to extension status change.");
|
||||
|
||||
HandleRequestStatus(OutputReportRequestStatus{});
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ void WiimoteScannerAndroid::FindWiimotes(std::vector<Wiimote*>& found_wiimotes,
|
||||
found_wiimotes.clear();
|
||||
found_board = nullptr;
|
||||
|
||||
NOTICE_LOG(WIIMOTE, "Finding Wiimotes");
|
||||
NOTICE_LOG_FMT(WIIMOTE, "Finding Wiimotes");
|
||||
|
||||
JNIEnv* env = IDCache::GetEnvForThread();
|
||||
|
||||
|
||||
@@ -24,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<Wiimote*>& found_wiimotes, Wi
|
||||
hci_inquiry(m_device_id, wait_len, max_infos, lap, &scan_infos_ptr, IREQ_CACHE_FLUSH);
|
||||
if (found_devices < 0)
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "Error searching for Bluetooth devices.");
|
||||
ERROR_LOG_FMT(WIIMOTE, "Error searching for Bluetooth devices.");
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG(WIIMOTE, "Found %i Bluetooth device(s).", found_devices);
|
||||
DEBUG_LOG_FMT(WIIMOTE, "Found {} Bluetooth device(s).", found_devices);
|
||||
|
||||
// Display discovered devices
|
||||
for (int i = 0; i < found_devices; ++i)
|
||||
{
|
||||
NOTICE_LOG(WIIMOTE, "found a device...");
|
||||
NOTICE_LOG_FMT(WIIMOTE, "found a device...");
|
||||
|
||||
// BT names are a maximum of 248 bytes apparently
|
||||
char name[255] = {};
|
||||
if (hci_read_remote_name(m_device_sock, &scan_infos[i].bdaddr, sizeof(name), name, 1000) < 0)
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "name request failed");
|
||||
ERROR_LOG_FMT(WIIMOTE, "name request failed");
|
||||
continue;
|
||||
}
|
||||
|
||||
NOTICE_LOG(WIIMOTE, "device name %s", name);
|
||||
NOTICE_LOG_FMT(WIIMOTE, "device name {}", name);
|
||||
if (!IsValidDeviceName(name))
|
||||
continue;
|
||||
|
||||
@@ -100,12 +100,12 @@ void WiimoteScannerLinux::FindWiimotes(std::vector<Wiimote*>& found_wiimotes, Wi
|
||||
if (IsBalanceBoardName(name))
|
||||
{
|
||||
found_board = wm;
|
||||
NOTICE_LOG(WIIMOTE, "Found balance board (%s).", bdaddr_str);
|
||||
NOTICE_LOG_FMT(WIIMOTE, "Found balance board ({}).", bdaddr_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
found_wiimotes.push_back(wm);
|
||||
NOTICE_LOG(WIIMOTE, "Found Wiimote (%s).", bdaddr_str);
|
||||
NOTICE_LOG_FMT(WIIMOTE, "Found Wiimote ({}).", bdaddr_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ WiimoteLinux::WiimoteLinux(bdaddr_t bdaddr) : m_bdaddr(bdaddr)
|
||||
int fds[2];
|
||||
if (pipe(fds))
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "pipe failed");
|
||||
ERROR_LOG_FMT(WIIMOTE, "pipe failed");
|
||||
abort();
|
||||
}
|
||||
m_wakeup_pipe_w = fds[1];
|
||||
@@ -152,7 +152,7 @@ bool WiimoteLinux::ConnectInternal()
|
||||
// If opening channel fails sleep and try again
|
||||
if (retry == 3)
|
||||
{
|
||||
WARN_LOG(WIIMOTE, "Unable to connect control channel of Wiimote: %s", strerror(errno));
|
||||
WARN_LOG_FMT(WIIMOTE, "Unable to connect control channel of Wiimote: {}", strerror(errno));
|
||||
close(m_cmd_sock);
|
||||
m_cmd_sock = -1;
|
||||
return false;
|
||||
@@ -163,7 +163,7 @@ bool WiimoteLinux::ConnectInternal()
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN_LOG(WIIMOTE, "Unable to open control socket to Wiimote: %s", strerror(errno));
|
||||
WARN_LOG_FMT(WIIMOTE, "Unable to open control socket to Wiimote: {}", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,8 @@ bool WiimoteLinux::ConnectInternal()
|
||||
// If opening channel fails sleep and try again
|
||||
if (retry == 3)
|
||||
{
|
||||
WARN_LOG(WIIMOTE, "Unable to connect interrupt channel of Wiimote: %s", strerror(errno));
|
||||
WARN_LOG_FMT(WIIMOTE, "Unable to connect interrupt channel of Wiimote: {}",
|
||||
strerror(errno));
|
||||
close(m_int_sock);
|
||||
close(m_cmd_sock);
|
||||
m_int_sock = m_cmd_sock = -1;
|
||||
@@ -189,7 +190,7 @@ bool WiimoteLinux::ConnectInternal()
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN_LOG(WIIMOTE, "Unable to open interrupt socket to Wiimote: %s", strerror(errno));
|
||||
WARN_LOG_FMT(WIIMOTE, "Unable to open interrupt socket to Wiimote: {}", strerror(errno));
|
||||
close(m_cmd_sock);
|
||||
m_int_sock = m_cmd_sock = -1;
|
||||
return false;
|
||||
@@ -217,7 +218,7 @@ void WiimoteLinux::IOWakeup()
|
||||
char c = 0;
|
||||
if (write(m_wakeup_pipe_w, &c, 1) != 1)
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "Unable to write to wakeup pipe.");
|
||||
ERROR_LOG_FMT(WIIMOTE, "Unable to write to wakeup pipe.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +239,7 @@ int WiimoteLinux::IORead(u8* buf)
|
||||
|
||||
if (poll(pollfds.data(), pollfds.size(), -1) == -1)
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "Unable to poll Wiimote %i input socket.", m_index + 1);
|
||||
ERROR_LOG_FMT(WIIMOTE, "Unable to poll Wiimote {} input socket.", m_index + 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -247,7 +248,7 @@ int WiimoteLinux::IORead(u8* buf)
|
||||
char c;
|
||||
if (read(m_wakeup_pipe_r, &c, 1) != 1)
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "Unable to read from wakeup pipe.");
|
||||
ERROR_LOG_FMT(WIIMOTE, "Unable to read from wakeup pipe.");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -260,15 +261,15 @@ int WiimoteLinux::IORead(u8* buf)
|
||||
if (r == -1)
|
||||
{
|
||||
// Error reading data
|
||||
ERROR_LOG(WIIMOTE, "Receiving data from Wiimote %i.", m_index + 1);
|
||||
ERROR_LOG_FMT(WIIMOTE, "Receiving data from Wiimote {}.", m_index + 1);
|
||||
|
||||
if (errno == ENOTCONN)
|
||||
{
|
||||
// This can happen if the Bluetooth dongle is disconnected
|
||||
ERROR_LOG(WIIMOTE,
|
||||
"Bluetooth appears to be disconnected. "
|
||||
"Wiimote %i will be disconnected.",
|
||||
m_index + 1);
|
||||
ERROR_LOG_FMT(WIIMOTE,
|
||||
"Bluetooth appears to be disconnected. "
|
||||
"Wiimote {} will be disconnected.",
|
||||
m_index + 1);
|
||||
}
|
||||
|
||||
r = 0;
|
||||
|
||||
@@ -180,7 +180,8 @@ void init_lib()
|
||||
// all nullptr.
|
||||
if (!load_hid() || !load_bthprops())
|
||||
{
|
||||
NOTICE_LOG(WIIMOTE, "Failed to load Bluetooth support libraries, Wiimotes will not function");
|
||||
NOTICE_LOG_FMT(WIIMOTE,
|
||||
"Failed to load Bluetooth support libraries, Wiimotes will not function");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -232,20 +233,21 @@ std::wstring GetDeviceProperty(const HDEVINFO& device_info, const PSP_DEVINFO_DA
|
||||
|
||||
int IOWritePerSetOutputReport(HANDLE& dev_handle, const u8* buf, size_t len, DWORD* written)
|
||||
{
|
||||
BOOLEAN result = pHidD_SetOutputReport(dev_handle, const_cast<u8*>(buf) + 1, (ULONG)(len - 1));
|
||||
const BOOLEAN result =
|
||||
pHidD_SetOutputReport(dev_handle, const_cast<u8*>(buf) + 1, (ULONG)(len - 1));
|
||||
if (!result)
|
||||
{
|
||||
DWORD err = GetLastError();
|
||||
const DWORD err = GetLastError();
|
||||
if (err == ERROR_SEM_TIMEOUT)
|
||||
{
|
||||
NOTICE_LOG(WIIMOTE, "IOWrite[WWM_SET_OUTPUT_REPORT]: Unable to send data to the Wiimote");
|
||||
NOTICE_LOG_FMT(WIIMOTE, "IOWrite[WWM_SET_OUTPUT_REPORT]: Unable to send data to the Wiimote");
|
||||
}
|
||||
else if (err != ERROR_GEN_FAILURE)
|
||||
{
|
||||
// Some third-party adapters (DolphinBar) use this
|
||||
// error code to signal the absence of a Wiimote
|
||||
// linked to the HID device.
|
||||
WARN_LOG(WIIMOTE, "IOWrite[WWM_SET_OUTPUT_REPORT]: Error: %08x", err);
|
||||
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_SET_OUTPUT_REPORT]: Error: {:08x}", err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,14 +290,14 @@ int IOWritePerWriteFile(HANDLE& dev_handle, OVERLAPPED& hid_overlap_write,
|
||||
switch (error)
|
||||
{
|
||||
case ERROR_INVALID_USER_BUFFER:
|
||||
INFO_LOG(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: Falling back to SetOutputReport");
|
||||
INFO_LOG_FMT(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: Falling back to SetOutputReport");
|
||||
write_method = WWM_SET_OUTPUT_REPORT;
|
||||
return IOWritePerSetOutputReport(dev_handle, buf, len, written);
|
||||
case ERROR_IO_PENDING:
|
||||
// Pending is no error!
|
||||
break;
|
||||
default:
|
||||
WARN_LOG(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: Error on WriteFile: %08x", error);
|
||||
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: Error on WriteFile: {:08x}", error);
|
||||
CancelIo(dev_handle);
|
||||
return 0;
|
||||
}
|
||||
@@ -311,13 +313,13 @@ int IOWritePerWriteFile(HANDLE& dev_handle, OVERLAPPED& hid_overlap_write,
|
||||
|
||||
if (WAIT_TIMEOUT == wait_result)
|
||||
{
|
||||
WARN_LOG(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: A timeout occurred on writing to Wiimote.");
|
||||
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: A timeout occurred on writing to Wiimote.");
|
||||
CancelIo(dev_handle);
|
||||
return 1;
|
||||
}
|
||||
else if (WAIT_FAILED == wait_result)
|
||||
{
|
||||
WARN_LOG(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: A wait error occurred on writing to Wiimote.");
|
||||
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: A wait error occurred on writing to Wiimote.");
|
||||
CancelIo(dev_handle);
|
||||
return 1;
|
||||
}
|
||||
@@ -407,7 +409,7 @@ bool CheckForToshibaStack(const DEVINST& hid_interface_device_instance)
|
||||
return (class_driver_provider == L"TOSHIBA");
|
||||
}
|
||||
|
||||
DEBUG_LOG(WIIMOTE, "Unable to detect class driver provider!");
|
||||
DEBUG_LOG_FMT(WIIMOTE, "Unable to detect class driver provider!");
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -477,7 +479,7 @@ bool IsWiimote(const std::basic_string<TCHAR>& device_path, WinWriteMethod& meth
|
||||
case InputReportID::Status:
|
||||
return true;
|
||||
default:
|
||||
WARN_LOG(WIIMOTE, "IsWiimote(): Received unexpected report %02x", buf[1]);
|
||||
WARN_LOG_FMT(WIIMOTE, "IsWiimote(): Received unexpected report {:02x}", buf[1]);
|
||||
invalid_report_count++;
|
||||
// If we receive over 15 invalid reports, then this is probably not a Wiimote.
|
||||
if (invalid_report_count > 15)
|
||||
@@ -637,8 +639,6 @@ bool WiimoteWindows::ConnectInternal()
|
||||
TCHAR name[128] = {};
|
||||
pHidD_GetProductString(dev_handle, name, 128);
|
||||
|
||||
//ERROR_LOG(WIIMOTE, "Product string: %s", TStrToUTF8(name).c_str());
|
||||
|
||||
if (!IsValidBluetoothName(TStrToUTF8(name)))
|
||||
{
|
||||
CloseHandle(dev_handle);
|
||||
@@ -664,7 +664,7 @@ bool WiimoteWindows::ConnectInternal()
|
||||
/*
|
||||
if (!SetThreadPriority(m_wiimote_thread.native_handle(), THREAD_PRIORITY_TIME_CRITICAL))
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "Failed to set Wiimote thread priority");
|
||||
ERROR_LOG_FMT(WIIMOTE, "Failed to set Wiimote thread priority");
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -756,7 +756,8 @@ int IORead(HANDLE& dev_handle, OVERLAPPED& hid_overlap_read, u8* buf, int index)
|
||||
return -1;
|
||||
}
|
||||
|
||||
WARN_LOG(WIIMOTE, "GetOverlappedResult error %d on Wiimote %i.", overlapped_err, index + 1);
|
||||
WARN_LOG_FMT(WIIMOTE, "GetOverlappedResult error {} on Wiimote {}.", overlapped_err,
|
||||
index + 1);
|
||||
return 0;
|
||||
}
|
||||
// If IOWakeup sets the event so GetOverlappedResult returns prematurely, but the request is
|
||||
@@ -770,17 +771,17 @@ int IORead(HANDLE& dev_handle, OVERLAPPED& hid_overlap_read, u8* buf, int index)
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN_LOG(WIIMOTE, "ReadFile error %d on Wiimote %i.", read_err, index + 1);
|
||||
WARN_LOG_FMT(WIIMOTE, "ReadFile error {} on Wiimote {}.", read_err, index + 1);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ReadFile will always return 22 bytes read.
|
||||
// So we need to calculate the actual report size by its report ID
|
||||
DWORD report_size = static_cast<DWORD>(GetReportSize(buf[1]));
|
||||
const auto report_size = static_cast<DWORD>(GetReportSize(buf[1]));
|
||||
if (report_size == 0)
|
||||
{
|
||||
WARN_LOG(WIIMOTE, "Received unsupported report %d in Wii Remote %i", buf[1], index + 1);
|
||||
WARN_LOG_FMT(WIIMOTE, "Received unsupported report {} in Wii Remote {}", buf[1], index + 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -894,8 +895,8 @@ void ProcessWiimotes(bool new_scan, const T& callback)
|
||||
while (hFindDevice)
|
||||
{
|
||||
// btdi.szName is sometimes missing it's content - it's a bt feature..
|
||||
DEBUG_LOG(WIIMOTE, "Authenticated %i connected %i remembered %i ", btdi.fAuthenticated,
|
||||
btdi.fConnected, btdi.fRemembered);
|
||||
DEBUG_LOG_FMT(WIIMOTE, "Authenticated {} connected {} remembered {} ", btdi.fAuthenticated,
|
||||
btdi.fConnected, btdi.fRemembered);
|
||||
|
||||
if (IsValidDeviceName(WStringToUTF8(btdi.szName)))
|
||||
{
|
||||
@@ -925,7 +926,7 @@ void RemoveWiimote(BLUETOOTH_DEVICE_INFO_STRUCT& btdi)
|
||||
{
|
||||
if (SUCCEEDED(pBluetoothRemoveDevice(&btdi.Address)))
|
||||
{
|
||||
NOTICE_LOG(WIIMOTE, "Removed BT Device", GetLastError());
|
||||
NOTICE_LOG_FMT(WIIMOTE, "Removed BT Device {}", GetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -939,8 +940,9 @@ bool AttachWiimote(HANDLE hRadio, const BLUETOOTH_RADIO_INFO& radio_info,
|
||||
{
|
||||
auto const& wm_addr = btdi.Address.rgBytes;
|
||||
|
||||
NOTICE_LOG(WIIMOTE, "Found Wiimote (%02x:%02x:%02x:%02x:%02x:%02x). Enabling HID service.",
|
||||
wm_addr[0], wm_addr[1], wm_addr[2], wm_addr[3], wm_addr[4], wm_addr[5]);
|
||||
NOTICE_LOG_FMT(
|
||||
WIIMOTE, "Found Wiimote ({:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}). Enabling HID service.",
|
||||
wm_addr[0], wm_addr[1], wm_addr[2], wm_addr[3], wm_addr[4], wm_addr[5]);
|
||||
|
||||
#if defined(AUTHENTICATE_WIIMOTES)
|
||||
// Authenticate
|
||||
@@ -953,7 +955,8 @@ bool AttachWiimote(HANDLE hRadio, const BLUETOOTH_RADIO_INFO& radio_info,
|
||||
|
||||
if (ERROR_SUCCESS != auth_result)
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "AttachWiimote: BluetoothAuthenticateDeviceEx returned %08x", auth_result);
|
||||
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothAuthenticateDeviceEx returned {:08x}",
|
||||
auth_result);
|
||||
}
|
||||
|
||||
DWORD pcServices = 16;
|
||||
@@ -964,8 +967,8 @@ bool AttachWiimote(HANDLE hRadio, const BLUETOOTH_RADIO_INFO& radio_info,
|
||||
|
||||
if (ERROR_SUCCESS != srv_result)
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "AttachWiimote: BluetoothEnumerateInstalledServices returned %08x",
|
||||
srv_result);
|
||||
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothEnumerateInstalledServices returned {:08x}",
|
||||
srv_result);
|
||||
}
|
||||
#endif
|
||||
// Activate service
|
||||
@@ -976,7 +979,7 @@ bool AttachWiimote(HANDLE hRadio, const BLUETOOTH_RADIO_INFO& radio_info,
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "AttachWiimote: BluetoothSetServiceState returned %08x", hr);
|
||||
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothSetServiceState returned {:08x}", hr);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -996,13 +999,13 @@ bool ForgetWiimote(BLUETOOTH_DEVICE_INFO_STRUCT& btdi)
|
||||
// Sometimes SetServiceState takes a while..
|
||||
auto const avoid_forget_seconds = 5.0;
|
||||
|
||||
auto pair_time = s_connect_times.find(btdi.Address.ullLong);
|
||||
const auto pair_time = s_connect_times.find(btdi.Address.ullLong);
|
||||
if (pair_time == s_connect_times.end() ||
|
||||
std::difftime(time(nullptr), pair_time->second) >= avoid_forget_seconds)
|
||||
{
|
||||
// Make Windows forget about device so it will re-find it if visible.
|
||||
// This is also required to detect a disconnect for some reason..
|
||||
NOTICE_LOG(WIIMOTE, "Removing remembered Wiimote.");
|
||||
NOTICE_LOG_FMT(WIIMOTE, "Removing remembered Wiimote.");
|
||||
pBluetoothRemoveDevice(&btdi.Address);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ void WiimoteScannerDarwin::FindWiimotes(std::vector<Wiimote*>& 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<Wiimote*>& 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<Wiimote*>& 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();
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ static bool IsDeviceUsable(const std::string& device_path)
|
||||
hid_device* handle = hid_open_path(device_path.c_str());
|
||||
if (handle == nullptr)
|
||||
{
|
||||
ERROR_LOG(WIIMOTE,
|
||||
"Could not connect to Wii Remote at \"%s\". "
|
||||
"Do you have permission to access the device?",
|
||||
device_path.c_str());
|
||||
ERROR_LOG_FMT(WIIMOTE,
|
||||
"Could not connect to Wii Remote at \"{}\". "
|
||||
"Do you have permission to access the device?",
|
||||
device_path);
|
||||
return false;
|
||||
}
|
||||
// Some third-party adapters (DolphinBar) always expose all four Wii Remotes as HIDs
|
||||
@@ -31,7 +31,7 @@ static bool IsDeviceUsable(const std::string& device_path)
|
||||
const int result = hid_write(handle, report, sizeof(report));
|
||||
// The DolphinBar uses EPIPE to signal the absence of a Wii Remote connected to this HID.
|
||||
if (result == -1 && errno != EPIPE)
|
||||
ERROR_LOG(WIIMOTE, "Couldn't write to Wii Remote at \"%s\".", device_path.c_str());
|
||||
ERROR_LOG_FMT(WIIMOTE, "Couldn't write to Wii Remote at \"{}\".", device_path);
|
||||
|
||||
hid_close(handle);
|
||||
return result != -1;
|
||||
@@ -48,7 +48,7 @@ WiimoteScannerHidapi::WiimoteScannerHidapi()
|
||||
WiimoteScannerHidapi::~WiimoteScannerHidapi()
|
||||
{
|
||||
if (hid_exit() == -1)
|
||||
ERROR_LOG(WIIMOTE, "Failed to clean up hidapi.");
|
||||
ERROR_LOG_FMT(WIIMOTE, "Failed to clean up hidapi.");
|
||||
}
|
||||
|
||||
bool WiimoteScannerHidapi::IsReady() const
|
||||
@@ -75,10 +75,10 @@ void WiimoteScannerHidapi::FindWiimotes(std::vector<Wiimote*>& wiimotes, Wiimote
|
||||
else
|
||||
wiimotes.push_back(wiimote);
|
||||
|
||||
NOTICE_LOG(WIIMOTE, "Found %s at %s: %ls %ls (%04hx:%04hx)",
|
||||
is_balance_board ? "balance board" : "Wiimote", device->path,
|
||||
device->manufacturer_string, device->product_string, device->vendor_id,
|
||||
device->product_id);
|
||||
NOTICE_LOG_FMT(WIIMOTE, "Found {} at {}: {} {} ({:04x}:{:04x})",
|
||||
is_balance_board ? "balance board" : "Wiimote", device->path,
|
||||
WStringToUTF8(device->manufacturer_string),
|
||||
WStringToUTF8(device->product_string), device->vendor_id, device->product_id);
|
||||
}
|
||||
hid_free_enumeration(list);
|
||||
}
|
||||
@@ -100,10 +100,10 @@ bool WiimoteHidapi::ConnectInternal()
|
||||
m_handle = hid_open_path(m_device_path.c_str());
|
||||
if (m_handle == nullptr)
|
||||
{
|
||||
ERROR_LOG(WIIMOTE,
|
||||
"Could not connect to Wii Remote at \"%s\". "
|
||||
"Do you have permission to access the device?",
|
||||
m_device_path.c_str());
|
||||
ERROR_LOG_FMT(WIIMOTE,
|
||||
"Could not connect to Wii Remote at \"{}\". "
|
||||
"Do you have permission to access the device?",
|
||||
m_device_path);
|
||||
}
|
||||
return m_handle != nullptr;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ int WiimoteHidapi::IORead(u8* buf)
|
||||
// TODO: If and once we use hidapi across plaforms, change our internal API to clean up this mess.
|
||||
if (result == -1)
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "Failed to read from %s.", m_device_path.c_str());
|
||||
ERROR_LOG_FMT(WIIMOTE, "Failed to read from {}.", m_device_path);
|
||||
return 0; // error
|
||||
}
|
||||
if (result == 0)
|
||||
@@ -143,7 +143,7 @@ int WiimoteHidapi::IOWrite(const u8* buf, size_t len)
|
||||
int result = hid_write(m_handle, buf + 1, len - 1);
|
||||
if (result == -1)
|
||||
{
|
||||
ERROR_LOG(WIIMOTE, "Failed to write to %s.", m_device_path.c_str());
|
||||
ERROR_LOG_FMT(WIIMOTE, "Failed to write to {}.", m_device_path);
|
||||
return 0;
|
||||
}
|
||||
return (result == 0) ? 1 : result;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user