InputCommon: Migrate logging over to fmt

Continues the migration of the logging calls over to the fmt capable
ones.
This commit is contained in:
Lioncash 2020-10-22 17:49:29 -04:00
parent 64f7a4448b
commit a5e1415e74
14 changed files with 215 additions and 185 deletions

View File

@ -222,7 +222,7 @@ void ControllerInterface::AddDevice(std::shared_ptr<ciface::Core::Device> device
device->SetId(id);
}
NOTICE_LOG(SERIALINTERFACE, "Added device: %s", device->GetQualifiedName().c_str());
NOTICE_LOG_FMT(SERIALINTERFACE, "Added device: {}", device->GetQualifiedName());
m_devices.emplace_back(std::move(device));
}
@ -237,7 +237,7 @@ void ControllerInterface::RemoveDevice(std::function<bool(const ciface::Core::De
auto it = std::remove_if(m_devices.begin(), m_devices.end(), [&callback](const auto& dev) {
if (callback(dev.get()))
{
NOTICE_LOG(SERIALINTERFACE, "Removed device: %s", dev->GetQualifiedName().c_str());
NOTICE_LOG_FMT(SERIALINTERFACE, "Removed device: {}", dev->GetQualifiedName());
return true;
}
return false;

View File

@ -42,7 +42,7 @@ std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device)
}
else
{
ERROR_LOG(PAD, "GetProperty(DIPROP_PRODUCTNAME) failed.");
ERROR_LOG_FMT(PAD, "GetProperty(DIPROP_PRODUCTNAME) failed.");
}
return result;
@ -58,7 +58,7 @@ void PopulateDevices(HWND hwnd)
if (FAILED(DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8,
(LPVOID*)&idi8, nullptr)))
{
ERROR_LOG(PAD, "DirectInput8Create failed.");
ERROR_LOG_FMT(PAD, "DirectInput8Create failed.");
return;
}

View File

@ -59,7 +59,7 @@ void InitJoystick(IDirectInput8* const idi8, HWND hwnd)
if (FAILED(js_device->SetCooperativeLevel(GetAncestor(hwnd, GA_ROOT),
DISCL_BACKGROUND | DISCL_EXCLUSIVE)))
{
WARN_LOG(
WARN_LOG_FMT(
PAD,
"DInput: Failed to acquire device exclusively. Force feedback will be unavailable.");
// Fall back to non-exclusive mode, with no rumble
@ -187,7 +187,7 @@ Joystick::~Joystick()
}
else
{
ERROR_LOG(PAD, "DInputJoystick: GetDeviceInfo failed.");
ERROR_LOG_FMT(PAD, "DInputJoystick: GetDeviceInfo failed.");
}
DeInitForceFeedback();

View File

@ -215,7 +215,7 @@ static sf::Socket::Status ReceiveWithTimeout(sf::UdpSocket& socket, void* data,
static void HotplugThreadFunc()
{
Common::SetCurrentThreadName("DualShockUDPClient Hotplug Thread");
INFO_LOG(SERIALINTERFACE, "DualShockUDPClient hotplug thread started");
INFO_LOG_FMT(SERIALINTERFACE, "DualShockUDPClient hotplug thread started");
while (s_hotplug_thread_running.IsSet())
{
@ -235,7 +235,7 @@ static void HotplugThreadFunc()
if (server.m_socket.send(&list_ports, sizeof list_ports, server.m_address, server.m_port) !=
sf::Socket::Status::Done)
{
ERROR_LOG(SERIALINTERFACE, "DualShockUDPClient HotplugThreadFunc send failed");
ERROR_LOG_FMT(SERIALINTERFACE, "DualShockUDPClient HotplugThreadFunc send failed");
}
}
}
@ -269,7 +269,7 @@ static void HotplugThreadFunc()
}
}
}
INFO_LOG(SERIALINTERFACE, "DualShockUDPClient hotplug thread stopped");
INFO_LOG_FMT(SERIALINTERFACE, "DualShockUDPClient hotplug thread stopped");
}
static void StartHotplugThread()
@ -302,7 +302,7 @@ static void StopHotplugThread()
static void Restart()
{
INFO_LOG(SERIALINTERFACE, "DualShockUDPClient Restart");
INFO_LOG_FMT(SERIALINTERFACE, "DualShockUDPClient Restart");
StopHotplugThread();
@ -384,7 +384,7 @@ void Init()
void PopulateDevices()
{
INFO_LOG(SERIALINTERFACE, "DualShockUDPClient PopulateDevices");
INFO_LOG_FMT(SERIALINTERFACE, "DualShockUDPClient PopulateDevices");
for (auto& server : s_servers)
{
@ -496,7 +496,9 @@ void Device::UpdateInput()
msg.Finish();
if (m_socket.send(&data_req, sizeof(data_req), m_server_address, m_server_port) !=
sf::Socket::Status::Done)
ERROR_LOG(SERIALINTERFACE, "DualShockUDPClient UpdateInput send failed");
{
ERROR_LOG_FMT(SERIALINTERFACE, "DualShockUDPClient UpdateInput send failed");
}
}
// Receive and handle controller data

View File

@ -242,14 +242,15 @@ struct Message
template <class ToMsgType>
std::optional<ToMsgType> CheckAndCastTo()
{
u32 crc32_in_header = m_message.header.crc32;
const u32 crc32_in_header = m_message.header.crc32;
// zero out the crc32 in the packet once we got it since that's whats needed for calculation
m_message.header.crc32 = 0;
u32 crc32_calculated = CRC32(&m_message, sizeof(ToMsgType));
const u32 crc32_calculated = CRC32(&m_message, sizeof(ToMsgType));
if (crc32_in_header != crc32_calculated)
{
NOTICE_LOG(SERIALINTERFACE,
"DualShockUDPClient Received message with bad CRC in header: got %u, expected %u",
NOTICE_LOG_FMT(
SERIALINTERFACE,
"DualShockUDPClient Received message with bad CRC in header: got {:08x}, expected {:08x}",
crc32_in_header, crc32_calculated);
return std::nullopt;
}

View File

@ -178,11 +178,11 @@ void Init(void* window)
HIDManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
if (!HIDManager)
ERROR_LOG(SERIALINTERFACE, "Failed to create HID Manager reference");
ERROR_LOG_FMT(SERIALINTERFACE, "Failed to create HID Manager reference");
IOHIDManagerSetDeviceMatching(HIDManager, nullptr);
if (IOHIDManagerOpen(HIDManager, kIOHIDOptionsTypeNone) != kIOReturnSuccess)
ERROR_LOG(SERIALINTERFACE, "Failed to open HID Manager");
ERROR_LOG_FMT(SERIALINTERFACE, "Failed to open HID Manager");
// Callbacks for acquisition or loss of a matching device
IOHIDManagerRegisterDeviceMatchingCallback(HIDManager, DeviceMatchingCallback, nullptr);
@ -198,7 +198,7 @@ void Init(void* window)
// Enable hotplugging
s_hotplug_thread = std::thread([] {
Common::SetCurrentThreadName("IOHIDManager Hotplug Thread");
NOTICE_LOG(SERIALINTERFACE, "IOHIDManager hotplug thread started");
NOTICE_LOG_FMT(SERIALINTERFACE, "IOHIDManager hotplug thread started");
IOHIDManagerScheduleWithRunLoop(HIDManager, CFRunLoopGetCurrent(), OurRunLoop);
s_stopper.AddToRunLoop(CFRunLoopGetCurrent(), OurRunLoop);
@ -206,7 +206,7 @@ void Init(void* window)
s_stopper.RemoveFromRunLoop(CFRunLoopGetCurrent(), OurRunLoop);
IOHIDManagerUnscheduleFromRunLoop(HIDManager, CFRunLoopGetCurrent(), OurRunLoop);
NOTICE_LOG(SERIALINTERFACE, "IOHIDManager hotplug thread stopped");
NOTICE_LOG_FMT(SERIALINTERFACE, "IOHIDManager hotplug thread stopped");
});
}

View File

@ -109,8 +109,8 @@ void Joystick::AddElements(CFArrayRef elements, std::set<IOHIDElementCookie>& co
break;
}
NOTICE_LOG(SERIALINTERFACE, "Unknown IOHIDElement, ignoring (Usage: %x, Type: %x)\n", usage,
IOHIDElementGetType(e));
NOTICE_LOG_FMT(SERIALINTERFACE, "Unknown IOHIDElement, ignoring (Usage: {:x}, Type: {:x})",
usage, IOHIDElementGetType(e));
break;
}

View File

@ -81,7 +81,7 @@ void Init()
{
#if !SDL_VERSION_ATLEAST(2, 0, 0)
if (SDL_Init(SDL_INIT_JOYSTICK) != 0)
ERROR_LOG(SERIALINTERFACE, "SDL failed to initialize");
ERROR_LOG_FMT(SERIALINTERFACE, "SDL failed to initialize");
return;
#else
s_hotplug_thread = std::thread([] {
@ -95,14 +95,14 @@ void Init()
if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC) != 0)
{
ERROR_LOG(SERIALINTERFACE, "SDL failed to initialize");
ERROR_LOG_FMT(SERIALINTERFACE, "SDL failed to initialize");
return;
}
const Uint32 custom_events_start = SDL_RegisterEvents(2);
if (custom_events_start == static_cast<Uint32>(-1))
{
ERROR_LOG(SERIALINTERFACE, "SDL failed to register custom events");
ERROR_LOG_FMT(SERIALINTERFACE, "SDL failed to register custom events");
return;
}
s_stop_event_type = custom_events_start;

View File

@ -112,7 +112,7 @@ void AddDevice(std::unique_ptr<WiimoteReal::Wiimote> wiimote)
if (!wiimote->Connect(CIFACE_WIIMOTE_INDEX))
{
WARN_LOG(WIIMOTE, "WiiRemote: Failed to connect.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Failed to connect.");
return;
}
@ -303,7 +303,7 @@ Device::~Device()
m_wiimote->EmuStop();
INFO_LOG(WIIMOTE, "WiiRemote: Returning remote to pool.");
INFO_LOG_FMT(WIIMOTE, "WiiRemote: Returning remote to pool.");
WiimoteReal::AddWiimoteToPool(std::move(m_wiimote));
}
@ -329,7 +329,7 @@ void Device::RunTasks()
AddReportHandler(std::function<void(const InputReportStatus& status)>(
[this](const InputReportStatus& status) {
DEBUG_LOG(WIIMOTE, "WiiRemote: Received requested status.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Received requested status.");
ProcessStatusReport(status);
}));
@ -346,11 +346,11 @@ void Device::RunTasks()
QueueReport(rpt, [this, desired_leds](ErrorCode result) {
if (result != ErrorCode::Success)
{
WARN_LOG(WIIMOTE, "WiiRemote: Failed to set LEDs.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Failed to set LEDs.");
return;
}
DEBUG_LOG(WIIMOTE, "WiiRemote: Set LEDs.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Set LEDs.");
m_leds = desired_leds;
});
@ -368,13 +368,13 @@ void Device::RunTasks()
QueueReport(mode, [this](ErrorCode error) {
if (error != ErrorCode::Success)
{
WARN_LOG(WIIMOTE, "WiiRemote: Failed to set reporting mode.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Failed to set reporting mode.");
return;
}
m_reporting_mode = desired_reporting_mode;
DEBUG_LOG(WIIMOTE, "WiiRemote: Set reporting mode.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Set reporting mode.");
});
return;
@ -389,11 +389,11 @@ void Device::RunTasks()
[this](ReadResponse response) {
if (!response)
{
WARN_LOG(WIIMOTE, "WiiRemote: Failed to read accelerometer calibration.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Failed to read accelerometer calibration.");
return;
}
DEBUG_LOG(WIIMOTE, "WiiRemote: Read accelerometer calibration.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Read accelerometer calibration.");
auto& calibration_data = *response;
@ -405,7 +405,7 @@ void Device::RunTasks()
// We could potentially try the second block at 0x26 if the checksum is bad.
if (accel_calibration.checksum != calibration_data.back())
WARN_LOG(WIIMOTE, "WiiRemote: Bad accelerometer calibration checksum.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Bad accelerometer calibration checksum.");
});
return;
@ -460,8 +460,7 @@ void Device::RunTasks()
// Note that this signal also DE-activates a M+.
WriteData(AddressSpace::I2CBus, WiimoteEmu::ExtensionPort::REPORT_I2C_SLAVE, INIT_ADDR,
{INIT_VALUE}, [this](ErrorCode result) {
DEBUG_LOG(WIIMOTE, "WiiRemote: Initialized extension: %d.", int(result));
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Initialized extension: {}.", int(result));
m_extension_id = std::nullopt;
});
@ -489,14 +488,14 @@ void Device::RunTasks()
[this](ReadResponse response) {
if (!response)
{
DEBUG_LOG(WIIMOTE, "WiiRemote: M+ poll failed.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: M+ poll failed.");
HandleMotionPlusNonResponse();
return;
}
WriteData(AddressSpace::I2CBus, WiimoteEmu::MotionPlus::INACTIVE_DEVICE_ADDR,
INIT_ADDR, {INIT_VALUE}, [this](ErrorCode result) {
DEBUG_LOG(WIIMOTE, "WiiRemote: M+ initialization: %d.", int(result));
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: M+ initialization: {}.", int(result));
if (result != ErrorCode::Success)
{
HandleMotionPlusNonResponse();
@ -563,7 +562,7 @@ void Device::RunTasks()
if (!response)
return;
DEBUG_LOG(WIIMOTE, "WiiRemote: Read M+ calibration.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Read M+ calibration.");
WiimoteEmu::MotionPlus::CalibrationData calibration =
Common::BitCastPtr<WiimoteEmu::MotionPlus::CalibrationData>(response->data());
@ -577,7 +576,7 @@ void Device::RunTasks()
if (read_checksum != std::pair(calibration.crc32_lsb, calibration.crc32_msb))
{
// We could potentially try another read or call the M+ unusable.
WARN_LOG(WIIMOTE, "WiiRemote: Bad M+ calibration checksum.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Bad M+ calibration checksum.");
}
});
@ -601,7 +600,7 @@ void Device::RunTasks()
if (!response)
return;
DEBUG_LOG(WIIMOTE, "WiiRemote: Read extension calibration.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Read extension calibration.");
auto& calibration_data = *response;
@ -616,7 +615,7 @@ void Device::RunTasks()
calibration_data[CALIBRATION_SIZE - 1]))
{
// We could potentially try another block or call the extension unusable.
WARN_LOG(WIIMOTE, "WiiRemote: Bad extension calibration checksum.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Bad extension calibration checksum.");
checksum = Checksum::Bad;
}
@ -704,14 +703,14 @@ void Device::ProcessExtensionID(u8 id_0, u8 id_4, u8 id_5)
{
if (id_4 == 0x00 && id_5 == 0x00)
{
INFO_LOG(WIIMOTE, "WiiRemote: Nunchuk is attached.");
INFO_LOG_FMT(WIIMOTE, "WiiRemote: Nunchuk is attached.");
m_extension_id = ExtensionID::Nunchuk;
m_mplus_desired_mode = MotionPlusState::PassthroughMode::Nunchuk;
}
else if (id_4 == 0x01 && id_5 == 0x01)
{
INFO_LOG(WIIMOTE, "WiiRemote: Classic Controller is attached.");
INFO_LOG_FMT(WIIMOTE, "WiiRemote: Classic Controller is attached.");
m_extension_id = ExtensionID::Classic;
m_mplus_desired_mode = MotionPlusState::PassthroughMode::Classic;
@ -719,7 +718,7 @@ void Device::ProcessExtensionID(u8 id_0, u8 id_4, u8 id_5)
else
{
// This is a normal occurance before extension initialization.
DEBUG_LOG(WIIMOTE, "WiiRemote: Unknown extension: %d %d %d.", id_0, id_4, id_5);
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Unknown extension: {} {} {}.", id_0, id_4, id_5);
m_extension_id = ExtensionID::Unsupported;
}
}
@ -727,7 +726,7 @@ void Device::ProcessExtensionID(u8 id_0, u8 id_4, u8 id_5)
void Device::MotionPlusState::SetCalibrationData(
const WiimoteEmu::MotionPlus::CalibrationData& data)
{
DEBUG_LOG(WIIMOTE, "WiiRemote: Set M+ calibration.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Set M+ calibration.");
calibration.emplace();
@ -748,7 +747,7 @@ Device::NunchukState::Calibration::Calibration() : accel{}, stick{}
void Device::NunchukState::SetCalibrationData(const WiimoteEmu::Nunchuk::CalibrationData& data,
Checksum checksum)
{
DEBUG_LOG(WIIMOTE, "WiiRemote: Set Nunchuk calibration.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Set Nunchuk calibration.");
calibration.emplace();
@ -759,16 +758,26 @@ void Device::NunchukState::SetCalibrationData(const WiimoteEmu::Nunchuk::Calibra
// We catch that here and fall back to "full range" calibration.
const auto stick_calibration = data.GetStick();
if (stick_calibration.IsSane())
{
calibration->stick = stick_calibration;
}
else
WARN_LOG(WIIMOTE, "WiiRemote: Nunchuk stick calibration is not sane. Using fallback values.");
{
WARN_LOG_FMT(WIIMOTE,
"WiiRemote: Nunchuk stick calibration is not sane. Using fallback values.");
}
// No known reports of bad accelerometer calibration but we'll handle it just in case.
const auto accel_calibration = data.GetAccel();
if (accel_calibration.IsSane())
{
calibration->accel = accel_calibration;
}
else
WARN_LOG(WIIMOTE, "WiiRemote: Nunchuk accel calibration is not sane. Using fallback values.");
{
WARN_LOG_FMT(WIIMOTE,
"WiiRemote: Nunchuk accel calibration is not sane. Using fallback values.");
}
}
Device::ClassicState::Calibration::Calibration()
@ -787,7 +796,7 @@ Device::ClassicState::Calibration::Calibration()
void Device::ClassicState::SetCalibrationData(const WiimoteEmu::Classic::CalibrationData& data,
Checksum checksum)
{
DEBUG_LOG(WIIMOTE, "WiiRemote: Set Classic Controller calibration.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Set Classic Controller calibration.");
calibration.emplace();
@ -796,16 +805,25 @@ void Device::ClassicState::SetCalibrationData(const WiimoteEmu::Classic::Calibra
const auto left_stick_calibration = data.GetLeftStick();
if (left_stick_calibration.IsSane())
{
calibration->left_stick = left_stick_calibration;
}
else
WARN_LOG(WIIMOTE, "WiiRemote: CC left stick calibration is not sane. Using fallback values.");
{
WARN_LOG_FMT(WIIMOTE,
"WiiRemote: CC left stick calibration is not sane. Using fallback values.");
}
const auto right_stick_calibration = data.GetRightStick();
if (right_stick_calibration.IsSane())
{
calibration->right_stick = right_stick_calibration;
}
else
WARN_LOG(WIIMOTE, "WiiRemote: CC right stick calibration is not sane. Using fallback values.");
{
WARN_LOG_FMT(WIIMOTE,
"WiiRemote: CC right stick calibration is not sane. Using fallback values.");
}
calibration->left_trigger = data.GetLeftTrigger();
calibration->right_trigger = data.GetRightTrigger();
}
@ -829,7 +847,7 @@ void Device::ReadActiveExtensionID()
m_mplus_state.current_mode = passthrough_mode;
INFO_LOG(WIIMOTE, "WiiRemote: M+ is active in mode: %d.", int(passthrough_mode));
INFO_LOG_FMT(WIIMOTE, "WiiRemote: M+ is active in mode: {}.", int(passthrough_mode));
}
else
{
@ -878,7 +896,7 @@ void Device::SetIRSensitivity(u32 level)
static constexpr u16 BLOCK1_ADDR = 0x00;
static constexpr u16 BLOCK2_ADDR = 0x1a;
DEBUG_LOG(WIIMOTE, "WiiRemote: Setting IR sensitivity: %d.", level + 1);
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Setting IR sensitivity: {}.", level + 1);
const auto& sensitivity_config = sensitivity_configs[level];
@ -886,7 +904,7 @@ void Device::SetIRSensitivity(u32 level)
sensitivity_config.block1, [&sensitivity_config, level, this](ErrorCode block_result) {
if (block_result != ErrorCode::Success)
{
WARN_LOG(WIIMOTE, "WiiRemote: Failed to write IR block 1.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Failed to write IR block 1.");
return;
}
@ -894,11 +912,11 @@ void Device::SetIRSensitivity(u32 level)
sensitivity_config.block2, [&, level, this](ErrorCode block2_result) {
if (block2_result != ErrorCode::Success)
{
WARN_LOG(WIIMOTE, "WiiRemote: Failed to write IR block 2.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Failed to write IR block 2.");
return;
}
DEBUG_LOG(WIIMOTE, "WiiRemote: IR sensitivity set.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: IR sensitivity set.");
m_ir_state.current_sensitivity = level;
});
@ -915,7 +933,7 @@ void Device::ConfigureIRCamera()
QueueReport(ir_logic2, [this](ErrorCode result) {
if (result != ErrorCode::Success)
{
WARN_LOG(WIIMOTE, "WiiRemote: Failed to enable IR.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Failed to enable IR.");
return;
}
@ -925,11 +943,11 @@ void Device::ConfigureIRCamera()
QueueReport(ir_logic, [this](ErrorCode ir_result) {
if (ir_result != ErrorCode::Success)
{
WARN_LOG(WIIMOTE, "WiiRemote: Failed to enable IR.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Failed to enable IR.");
return;
}
DEBUG_LOG(WIIMOTE, "WiiRemote: IR enabled.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: IR enabled.");
m_ir_state.enabled = true;
});
@ -955,7 +973,7 @@ void Device::ConfigureIRCamera()
{WiimoteEmu::CameraLogic::IR_MODE_BASIC}, [this](ErrorCode mode_result) {
if (mode_result != ErrorCode::Success)
{
WARN_LOG(WIIMOTE, "WiiRemote: Failed to set IR mode.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Failed to set IR mode.");
return;
}
@ -967,11 +985,11 @@ void Device::ConfigureIRCamera()
{ENABLE_VALUE}, [this](ErrorCode result) {
if (result != ErrorCode::Success)
{
WARN_LOG(WIIMOTE, "WiiRemote: Failed to enable object tracking.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Failed to enable object tracking.");
return;
}
DEBUG_LOG(WIIMOTE, "WiiRemote: IR mode set.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: IR mode set.");
m_ir_state.mode_set = true;
});
@ -987,7 +1005,7 @@ void Device::ConfigureSpeaker()
QueueReport(mute, [this](ErrorCode mute_result) {
if (mute_result != ErrorCode::Success)
{
WARN_LOG(WIIMOTE, "WiiRemote: Failed to mute speaker.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Failed to mute speaker.");
return;
}
@ -997,11 +1015,11 @@ void Device::ConfigureSpeaker()
QueueReport(spkr, [this](ErrorCode enable_result) {
if (enable_result != ErrorCode::Success)
{
WARN_LOG(WIIMOTE, "WiiRemote: Failed to disable speaker.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Failed to disable speaker.");
return;
}
DEBUG_LOG(WIIMOTE, "WiiRemote: Speaker muted and disabled.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Speaker muted and disabled.");
m_speaker_configured = true;
});
@ -1020,7 +1038,7 @@ void Device::TriggerMotionPlusModeChange()
WriteData(AddressSpace::I2CBus, device_addr, WiimoteEmu::MotionPlus::PASSTHROUGH_MODE_OFFSET,
{passthrough_mode}, [this](ErrorCode activation_result) {
DEBUG_LOG(WIIMOTE, "WiiRemote: M+ activation: %d.", int(activation_result));
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: M+ activation: {}.", int(activation_result));
WaitForMotionPlus();
@ -1041,7 +1059,7 @@ void Device::TriggerMotionPlusCalibration()
// It seems we're better off just manually determining "zero".
WriteData(AddressSpace::I2CBus, WiimoteEmu::MotionPlus::ACTIVE_DEVICE_ADDR,
CALIBRATION_TRIGGER_ADDR, {CALIBRATION_TRIGGER_VALUE}, [](ErrorCode result) {
DEBUG_LOG(WIIMOTE, "WiiRemote: M+ calibration trigger done: %d.", int(result));
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: M+ calibration trigger done: {}.", int(result));
});
}
@ -1065,7 +1083,7 @@ void Device::ProcessInputReport(WiimoteReal::Report& report)
{
if (report.size() < WiimoteReal::REPORT_HID_HEADER_SIZE)
{
WARN_LOG(WIIMOTE, "WiiRemote: Bad report size.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Bad report size.");
return;
}
@ -1080,7 +1098,7 @@ void Device::ProcessInputReport(WiimoteReal::Report& report)
if (report.size() - WiimoteReal::REPORT_HID_HEADER_SIZE <
sizeof(TypedInputData<InputReportStatus>))
{
WARN_LOG(WIIMOTE, "WiiRemote: Bad report size.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Bad report size.");
}
else
{
@ -1089,8 +1107,8 @@ void Device::ProcessInputReport(WiimoteReal::Report& report)
}
else if (report_id < InputReportID::ReportCore)
{
WARN_LOG(WIIMOTE, "WiiRemote: Unhandled input report: %s.",
ArrayToString(report.data(), u32(report.size())).c_str());
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Unhandled input report: {}.",
ArrayToString(report.data(), u32(report.size())));
}
break;
@ -1098,7 +1116,7 @@ void Device::ProcessInputReport(WiimoteReal::Report& report)
if (it->IsExpired())
{
WARN_LOG(WIIMOTE, "WiiRemote: Removing expired handler.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Removing expired handler.");
it = m_report_handlers.erase(it);
continue;
}
@ -1130,7 +1148,7 @@ void Device::ProcessInputReport(WiimoteReal::Report& report)
if (manipulator->GetDataSize() + WiimoteReal::REPORT_HID_HEADER_SIZE > report.size())
{
WARN_LOG(WIIMOTE, "WiiRemote: Bad report size.");
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Bad report size.");
return;
}
@ -1291,7 +1309,7 @@ void Device::ProcessMotionPlusExtensionData(const u8* ext_data, u32 ext_size)
{
m_mplus_state.passthrough_port = is_ext_connected;
DEBUG_LOG(WIIMOTE, "WiiRemote: M+ passthrough port event: %d.", is_ext_connected);
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: M+ passthrough port event: {}.", is_ext_connected);
// With no passthrough extension we'll be happy with the current mode.
if (!is_ext_connected)
@ -1308,7 +1326,7 @@ void Device::ProcessMotionPlusExtensionData(const u8* ext_data, u32 ext_size)
if (!IsMotionPlusInDesiredMode())
{
DEBUG_LOG(WIIMOTE, "WiiRemote: Ignoring unwanted passthrough data.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Ignoring unwanted passthrough data.");
return;
}
@ -1403,7 +1421,7 @@ bool Device::IsWaitingForMotionPlus() const
void Device::WaitForMotionPlus()
{
DEBUG_LOG(WIIMOTE, "WiiRemote: Wait for M+.");
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Wait for M+.");
m_mplus_wait_time = Clock::now() + std::chrono::seconds{2};
}
@ -1455,7 +1473,7 @@ void Device::AddReadDataReplyHandler(AddressSpace space, u8 slave, u16 address,
{
// Data read may return a busy ack.
auto ack_handler = MakeAckHandler(OutputReportID::ReadData, [callback](ErrorCode result) {
DEBUG_LOG(WIIMOTE, "WiiRemote: Read ack error: %d.", int(result));
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Read ack error: {}.", int(result));
callback(ReadResponse{});
});
@ -1468,7 +1486,7 @@ void Device::AddReadDataReplyHandler(AddressSpace space, u8 slave, u16 address,
if (reply.error != u8(ErrorCode::Success))
{
DEBUG_LOG(WIIMOTE, "WiiRemote: Read reply error: %d.", int(reply.error));
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Read reply error: {}.", int(reply.error));
callback(ReadResponse{});
return ReportHandler::HandlerResult::Handled;
@ -1557,8 +1575,8 @@ void Device::ReportHandler::AddHandler(std::function<R(const T&)> handler)
if (report.size() < sizeof(T) + WiimoteReal::REPORT_HID_HEADER_SIZE + 1)
{
// Off-brand "NEW 2in1" Wii Remote likes to shorten read data replies.
WARN_LOG(WIIMOTE, "WiiRemote: Bad report size (%d) for report 0x%x. Zero-filling.",
int(report.size()), int(T::REPORT_ID));
WARN_LOG_FMT(WIIMOTE, "WiiRemote: Bad report size ({}) for report {:#x}. Zero-filling.",
report.size(), int(T::REPORT_ID));
data = {};
std::memcpy(&data, report.data() + WiimoteReal::REPORT_HID_HEADER_SIZE + 1,
@ -1631,7 +1649,7 @@ void Device::ProcessStatusReport(const InputReportStatus& status)
// Handle extension port state change.
if (is_ext_connected != m_extension_port)
{
DEBUG_LOG(WIIMOTE, "WiiRemote: Extension port event: %d.", is_ext_connected);
DEBUG_LOG_FMT(WIIMOTE, "WiiRemote: Extension port event: {}.", is_ext_connected);
m_extension_port = is_ext_connected;

View File

@ -51,7 +51,7 @@ void ciface::Win32::Init(void* hwnd)
if (FAILED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED)))
{
ERROR_LOG(SERIALINTERFACE, "CoInitializeEx failed: %i", GetLastError());
ERROR_LOG_FMT(SERIALINTERFACE, "CoInitializeEx failed: {}", GetLastError());
return;
}
Common::ScopeGuard uninit([] { CoUninitialize(); });
@ -65,12 +65,12 @@ void ciface::Win32::Init(void* hwnd)
ATOM window_class = RegisterClassEx(&window_class_info);
if (!window_class)
{
NOTICE_LOG(SERIALINTERFACE, "RegisterClassEx failed: %i", GetLastError());
NOTICE_LOG_FMT(SERIALINTERFACE, "RegisterClassEx failed: {}", GetLastError());
return;
}
Common::ScopeGuard unregister([&window_class] {
if (!UnregisterClass(MAKEINTATOM(window_class), GetModuleHandle(nullptr)))
ERROR_LOG(SERIALINTERFACE, "UnregisterClass failed: %i", GetLastError());
ERROR_LOG_FMT(SERIALINTERFACE, "UnregisterClass failed: {}", GetLastError());
});
message_window = CreateWindowEx(0, L"Message", nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr,
@ -78,12 +78,12 @@ void ciface::Win32::Init(void* hwnd)
promise_guard.Exit();
if (!message_window)
{
ERROR_LOG(SERIALINTERFACE, "CreateWindowEx failed: %i", GetLastError());
ERROR_LOG_FMT(SERIALINTERFACE, "CreateWindowEx failed: {}", GetLastError());
return;
}
Common::ScopeGuard destroy([&] {
if (!DestroyWindow(message_window))
ERROR_LOG(SERIALINTERFACE, "DestroyWindow failed: %i", GetLastError());
ERROR_LOG_FMT(SERIALINTERFACE, "DestroyWindow failed: {}", GetLastError());
});
std::array<RAWINPUTDEVICE, 2> devices;
@ -101,7 +101,7 @@ void ciface::Win32::Init(void* hwnd)
if (!RegisterRawInputDevices(devices.data(), static_cast<UINT>(devices.size()),
static_cast<UINT>(sizeof(decltype(devices)::value_type))))
{
ERROR_LOG(SERIALINTERFACE, "RegisterRawInputDevices failed: %i", GetLastError());
ERROR_LOG_FMT(SERIALINTERFACE, "RegisterRawInputDevices failed: {}", GetLastError());
return;
}
@ -126,17 +126,18 @@ void ciface::Win32::PopulateDevices(void* hwnd)
s_done_populating.Reset();
PostMessage(s_message_window, WM_INPUT_DEVICE_CHANGE, 0, 0);
if (!s_done_populating.WaitFor(std::chrono::seconds(10)))
ERROR_LOG(SERIALINTERFACE, "win32 timed out when trying to populate devices");
ERROR_LOG_FMT(SERIALINTERFACE, "win32 timed out when trying to populate devices");
}
else
{
ERROR_LOG(SERIALINTERFACE, "win32 asked to populate devices, but device thread isn't running");
ERROR_LOG_FMT(SERIALINTERFACE,
"win32 asked to populate devices, but device thread isn't running");
}
}
void ciface::Win32::DeInit()
{
NOTICE_LOG(SERIALINTERFACE, "win32 DeInit");
NOTICE_LOG_FMT(SERIALINTERFACE, "win32 DeInit");
if (s_thread.joinable())
{
PostMessage(s_message_window, WM_DOLPHIN_STOP, 0, 0);

View File

@ -253,8 +253,8 @@ static void AddDeviceNode(const char* devnode)
auto evdev_device = FindDeviceWithUniqueIDAndPhysicalLocation(uniq, phys);
if (evdev_device)
{
NOTICE_LOG(SERIALINTERFACE, "evdev combining devices with unique id: %s, physical location: %s",
uniq, phys);
NOTICE_LOG_FMT(SERIALINTERFACE,
"evdev combining devices with unique id: {}, physical location: {}", uniq, phys);
evdev_device->AddNode(devnode, fd, dev);
@ -282,7 +282,7 @@ static void AddDeviceNode(const char* devnode)
static void HotplugThreadFunc()
{
Common::SetCurrentThreadName("evdev Hotplug Thread");
NOTICE_LOG(SERIALINTERFACE, "evdev hotplug thread started");
NOTICE_LOG_FMT(SERIALINTERFACE, "evdev hotplug thread started");
udev* const udev = udev_new();
Common::ScopeGuard udev_guard([udev] { udev_unref(udev); });
@ -337,7 +337,7 @@ static void HotplugThreadFunc()
AddDeviceNode(devnode);
}
}
NOTICE_LOG(SERIALINTERFACE, "evdev hotplug thread stopped");
NOTICE_LOG_FMT(SERIALINTERFACE, "evdev hotplug thread stopped");
}
static void StartHotplugThread()

View File

@ -40,7 +40,7 @@ DynamicInputTextureConfiguration::DynamicInputTextureConfiguration(const std::st
File::OpenFStream(json_stream, json_file, std::ios_base::in);
if (!json_stream.is_open())
{
ERROR_LOG(VIDEO, "Failed to load dynamic input json file '%s'", json_file.c_str());
ERROR_LOG_FMT(VIDEO, "Failed to load dynamic input json file '{}'", json_file);
m_valid = false;
return;
}
@ -50,8 +50,8 @@ DynamicInputTextureConfiguration::DynamicInputTextureConfiguration(const std::st
if (!error.empty())
{
ERROR_LOG(VIDEO, "Failed to load dynamic input json file '%s' due to parse error: %s",
json_file.c_str(), error.c_str());
ERROR_LOG_FMT(VIDEO, "Failed to load dynamic input json file '{}' due to parse error: {}",
json_file, error);
m_valid = false;
return;
}
@ -59,10 +59,11 @@ DynamicInputTextureConfiguration::DynamicInputTextureConfiguration(const std::st
const picojson::value& output_textures_json = out.get("output_textures");
if (!output_textures_json.is<picojson::object>())
{
ERROR_LOG(VIDEO,
"Failed to load dynamic input json file '%s' because 'output_textures' is missing or "
ERROR_LOG_FMT(
VIDEO,
"Failed to load dynamic input json file '{}' because 'output_textures' is missing or "
"was not of type object",
json_file.c_str());
json_file);
m_valid = false;
return;
}
@ -103,11 +104,11 @@ DynamicInputTextureConfiguration::DynamicInputTextureConfiguration(const std::st
if (!image.is<std::string>() || !emulated_controls.is<picojson::object>())
{
ERROR_LOG(VIDEO,
"Failed to load dynamic input json file '%s' because required fields "
ERROR_LOG_FMT(VIDEO,
"Failed to load dynamic input json file '{}' because required fields "
"'image', or 'emulated_controls' are either "
"missing or the incorrect type",
json_file.c_str());
json_file);
m_valid = false;
return;
}
@ -121,10 +122,10 @@ DynamicInputTextureConfiguration::DynamicInputTextureConfiguration(const std::st
const std::string image_full_path = m_base_path + texture_data.m_image_name;
if (!File::Exists(image_full_path))
{
ERROR_LOG(VIDEO,
"Failed to load dynamic input json file '%s' because the image '%s' "
ERROR_LOG_FMT(VIDEO,
"Failed to load dynamic input json file '{}' because the image '{}' "
"could not be loaded",
json_file.c_str(), image_full_path.c_str());
json_file, image_full_path);
m_valid = false;
return;
}
@ -134,10 +135,10 @@ DynamicInputTextureConfiguration::DynamicInputTextureConfiguration(const std::st
{
if (!map.is<picojson::object>())
{
ERROR_LOG(VIDEO,
"Failed to load dynamic input json file '%s' because 'emulated_controls' "
"map key '%s' is incorrect type. Expected map ",
json_file.c_str(), emulated_controller_name.c_str());
ERROR_LOG_FMT(VIDEO,
"Failed to load dynamic input json file '{}' because 'emulated_controls' "
"map key '{}' is incorrect type. Expected map ",
json_file, emulated_controller_name);
m_valid = false;
return;
}
@ -147,10 +148,11 @@ DynamicInputTextureConfiguration::DynamicInputTextureConfiguration(const std::st
{
if (!regions_array.is<picojson::array>())
{
ERROR_LOG(VIDEO,
"Failed to load dynamic input json file '%s' because emulated controller '%s' "
"key '%s' has incorrect value type. Expected array ",
json_file.c_str(), emulated_controller_name.c_str(), emulated_control.c_str());
ERROR_LOG_FMT(
VIDEO,
"Failed to load dynamic input json file '{}' because emulated controller '{}' "
"key '{}' has incorrect value type. Expected array ",
json_file, emulated_controller_name, emulated_control);
m_valid = false;
return;
}
@ -161,11 +163,11 @@ DynamicInputTextureConfiguration::DynamicInputTextureConfiguration(const std::st
Rect r;
if (!region.is<picojson::array>())
{
ERROR_LOG(
ERROR_LOG_FMT(
VIDEO,
"Failed to load dynamic input json file '%s' because emulated controller '%s' "
"key '%s' has a region with the incorrect type. Expected array ",
json_file.c_str(), emulated_controller_name.c_str(), emulated_control.c_str());
"Failed to load dynamic input json file '{}' because emulated controller '{}' "
"key '{}' has a region with the incorrect type. Expected array ",
json_file, emulated_controller_name, emulated_control);
m_valid = false;
return;
}
@ -174,12 +176,12 @@ DynamicInputTextureConfiguration::DynamicInputTextureConfiguration(const std::st
if (region_offsets.size() != 4)
{
ERROR_LOG(
ERROR_LOG_FMT(
VIDEO,
"Failed to load dynamic input json file '%s' because emulated controller '%s' "
"key '%s' has a region that does not have 4 offsets (left, top, right, "
"Failed to load dynamic input json file '{}' because emulated controller '{}' "
"key '{}' has a region that does not have 4 offsets (left, top, right, "
"bottom).",
json_file.c_str(), emulated_controller_name.c_str(), emulated_control.c_str());
json_file, emulated_controller_name, emulated_control);
m_valid = false;
return;
}
@ -187,11 +189,11 @@ DynamicInputTextureConfiguration::DynamicInputTextureConfiguration(const std::st
if (!std::all_of(region_offsets.begin(), region_offsets.end(),
[](picojson::value val) { return val.is<double>(); }))
{
ERROR_LOG(
ERROR_LOG_FMT(
VIDEO,
"Failed to load dynamic input json file '%s' because emulated controller '%s' "
"key '%s' has a region that has the incorrect offset type.",
json_file.c_str(), emulated_controller_name.c_str(), emulated_control.c_str());
"Failed to load dynamic input json file '{}' because emulated controller '{}' "
"key '{}' has a region that has the incorrect offset type.",
json_file, emulated_controller_name, emulated_control);
m_valid = false;
return;
}
@ -217,10 +219,10 @@ DynamicInputTextureConfiguration::DynamicInputTextureConfiguration(const std::st
if (host_controls.empty())
{
ERROR_LOG(VIDEO,
"Failed to load dynamic input json file '%s' because field "
ERROR_LOG_FMT(VIDEO,
"Failed to load dynamic input json file '{}' because field "
"'host_controls' is missing ",
json_file.c_str());
json_file);
m_valid = false;
return;
}
@ -229,10 +231,10 @@ DynamicInputTextureConfiguration::DynamicInputTextureConfiguration(const std::st
{
if (!map.is<picojson::object>())
{
ERROR_LOG(VIDEO,
"Failed to load dynamic input json file '%s' because 'host_controls' "
"map key '%s' is incorrect type ",
json_file.c_str(), host_device.c_str());
ERROR_LOG_FMT(VIDEO,
"Failed to load dynamic input json file '{}' because 'host_controls' "
"map key '{}' is incorrect type ",
json_file, host_device);
m_valid = false;
return;
}

View File

@ -88,7 +88,7 @@ static void Read()
int err = libusb_interrupt_transfer(s_handle, s_endpoint_in, s_controller_payload_swap,
sizeof(s_controller_payload_swap), &payload_size, 16);
if (err)
ERROR_LOG(SERIALINTERFACE, "adapter libusb read failed: err=%s", libusb_error_name(err));
ERROR_LOG_FMT(SERIALINTERFACE, "adapter libusb read failed: err={}", libusb_error_name(err));
{
std::lock_guard<std::mutex> lk(s_mutex);
@ -111,12 +111,17 @@ static void Write()
if (!s_adapter_thread_running.IsSet())
return;
u8 payload[5] = {0x11, s_controller_rumble[0], s_controller_rumble[1], s_controller_rumble[2],
s_controller_rumble[3]};
int err =
u8 payload[5] = {
0x11,
s_controller_rumble[0],
s_controller_rumble[1],
s_controller_rumble[2],
s_controller_rumble[3],
};
const int err =
libusb_interrupt_transfer(s_handle, s_endpoint_out, payload, sizeof(payload), &size, 16);
if (err)
ERROR_LOG(SERIALINTERFACE, "adapter libusb write failed: err=%s", libusb_error_name(err));
if (err != 0)
ERROR_LOG_FMT(SERIALINTERFACE, "adapter libusb write failed: err={}", libusb_error_name(err));
}
}
@ -149,7 +154,7 @@ static int HotplugCallback(libusb_context* ctx, libusb_device* dev, libusb_hotpl
static void ScanThreadFunc()
{
Common::SetCurrentThreadName("GC Adapter Scanning Thread");
NOTICE_LOG(SERIALINTERFACE, "GC Adapter scanning thread started");
NOTICE_LOG_FMT(SERIALINTERFACE, "GC Adapter scanning thread started");
#if defined(LIBUSB_API_VERSION) && LIBUSB_API_VERSION >= 0x01000102
#ifndef __FreeBSD__
@ -165,7 +170,7 @@ static void ScanThreadFunc()
nullptr, &s_hotplug_handle) != LIBUSB_SUCCESS)
s_libusb_hotplug_enabled = false;
if (s_libusb_hotplug_enabled)
NOTICE_LOG(SERIALINTERFACE, "Using libUSB hotplug detection");
NOTICE_LOG_FMT(SERIALINTERFACE, "Using libUSB hotplug detection");
}
#endif
@ -182,10 +187,10 @@ static void ScanThreadFunc()
else
Common::SleepCurrentThread(500);
}
NOTICE_LOG(SERIALINTERFACE, "GC Adapter scanning thread stopped");
NOTICE_LOG_FMT(SERIALINTERFACE, "GC Adapter scanning thread stopped");
}
void SetAdapterCallback(std::function<void(void)> func)
void SetAdapterCallback(std::function<void()> func)
{
s_detect_callback = func;
}
@ -257,10 +262,10 @@ static bool CheckDeviceAccess(libusb_device* device)
{
libusb_device_descriptor desc;
int ret = libusb_get_device_descriptor(device, &desc);
if (ret)
if (ret != 0)
{
// could not acquire the descriptor, no point in trying to use it.
ERROR_LOG(SERIALINTERFACE, "libusb_get_device_descriptor failed with error: %d", ret);
ERROR_LOG_FMT(SERIALINTERFACE, "libusb_get_device_descriptor failed with error: {}", ret);
return false;
}
@ -270,25 +275,26 @@ static bool CheckDeviceAccess(libusb_device* device)
return false;
}
NOTICE_LOG(SERIALINTERFACE, "Found GC Adapter with Vendor: %X Product: %X Devnum: %d",
NOTICE_LOG_FMT(SERIALINTERFACE, "Found GC Adapter with Vendor: {:X} Product: {:X} Devnum: {}",
desc.idVendor, desc.idProduct, 1);
// In case of failure, capture the libusb error code into the adapter status
Common::ScopeGuard status_guard([&ret] { s_status = ret; });
u8 bus = libusb_get_bus_number(device);
u8 port = libusb_get_device_address(device);
const u8 bus = libusb_get_bus_number(device);
const u8 port = libusb_get_device_address(device);
ret = libusb_open(device, &s_handle);
if (ret == LIBUSB_ERROR_ACCESS)
{
ERROR_LOG(SERIALINTERFACE,
"Dolphin does not have access to this device: Bus %03d Device %03d: ID %04X:%04X.",
ERROR_LOG_FMT(
SERIALINTERFACE,
"Dolphin does not have access to this device: Bus {:03d} Device {:03d}: ID {:04X}:{:04X}.",
bus, port, desc.idVendor, desc.idProduct);
return false;
}
if (ret)
if (ret != 0)
{
ERROR_LOG(SERIALINTERFACE, "libusb_open failed to open device with error = %d", ret);
ERROR_LOG_FMT(SERIALINTERFACE, "libusb_open failed to open device with error = {}", ret);
return false;
}
@ -297,14 +303,14 @@ static bool CheckDeviceAccess(libusb_device* device)
{
ret = libusb_detach_kernel_driver(s_handle, 0);
if (ret != 0 && ret != LIBUSB_ERROR_NOT_SUPPORTED)
ERROR_LOG(SERIALINTERFACE, "libusb_detach_kernel_driver failed with error: %d", ret);
ERROR_LOG_FMT(SERIALINTERFACE, "libusb_detach_kernel_driver failed with error: {}", ret);
}
// This call makes Nyko-brand (and perhaps other) adapters work.
// However it returns LIBUSB_ERROR_PIPE with Mayflash adapters.
const int transfer = libusb_control_transfer(s_handle, 0x21, 11, 0x0001, 0, nullptr, 0, 1000);
if (transfer < 0)
WARN_LOG(SERIALINTERFACE, "libusb_control_transfer failed with error: %d", transfer);
WARN_LOG_FMT(SERIALINTERFACE, "libusb_control_transfer failed with error: {}", transfer);
// this split is needed so that we don't avoid claiming the interface when
// detaching the kernel driver is successful
@ -316,9 +322,9 @@ static bool CheckDeviceAccess(libusb_device* device)
}
ret = libusb_claim_interface(s_handle, 0);
if (ret)
if (ret != 0)
{
ERROR_LOG(SERIALINTERFACE, "libusb_claim_interface failed with error: %d", ret);
ERROR_LOG_FMT(SERIALINTERFACE, "libusb_claim_interface failed with error: {}", ret);
libusb_close(s_handle);
s_handle = nullptr;
return false;
@ -404,7 +410,7 @@ static void Reset()
}
if (s_detect_callback != nullptr)
s_detect_callback();
NOTICE_LOG(SERIALINTERFACE, "GC Adapter detached");
NOTICE_LOG_FMT(SERIALINTERFACE, "GC Adapter detached");
}
GCPadStatus Input(int chan)
@ -430,7 +436,7 @@ GCPadStatus Input(int chan)
controller_payload_copy[0] != LIBUSB_DT_HID)
{
// This can occur for a few frames on initialization.
ERROR_LOG(SERIALINTERFACE, "error reading payload (size: %d, type: %02x)", payload_size,
ERROR_LOG_FMT(SERIALINTERFACE, "error reading payload (size: {}, type: {:02x})", payload_size,
controller_payload_copy[0]);
}
else
@ -440,7 +446,7 @@ GCPadStatus Input(int chan)
if (type != ControllerTypes::CONTROLLER_NONE &&
s_controller_type[chan] == ControllerTypes::CONTROLLER_NONE)
{
NOTICE_LOG(SERIALINTERFACE, "New device connected to Port %d of Type: %02x", chan + 1,
NOTICE_LOG_FMT(SERIALINTERFACE, "New device connected to Port {} of Type: {:02x}", chan + 1,
controller_payload_copy[1 + (9 * chan)]);
get_origin = true;
}
@ -545,7 +551,7 @@ static void ResetRumbleLockNeeded()
int size = 0;
libusb_interrupt_transfer(s_handle, s_endpoint_out, rumble, sizeof(rumble), &size, 16);
INFO_LOG(SERIALINTERFACE, "Rumble state reset");
INFO_LOG_FMT(SERIALINTERFACE, "Rumble state reset");
}
void Output(int chan, u8 rumble_command)

View File

@ -64,7 +64,7 @@ static u64 s_last_init = 0;
static void ScanThreadFunc()
{
Common::SetCurrentThreadName("GC Adapter Scanning Thread");
NOTICE_LOG(SERIALINTERFACE, "GC Adapter scanning thread started");
NOTICE_LOG_FMT(SERIALINTERFACE, "GC Adapter scanning thread started");
JNIEnv* env = IDCache::GetEnvForThread();
@ -78,13 +78,13 @@ static void ScanThreadFunc()
Common::SleepCurrentThread(1000);
}
NOTICE_LOG(SERIALINTERFACE, "GC Adapter scanning thread stopped");
NOTICE_LOG_FMT(SERIALINTERFACE, "GC Adapter scanning thread stopped");
}
static void Write()
{
Common::SetCurrentThreadName("GC Adapter Write Thread");
NOTICE_LOG(SERIALINTERFACE, "GC Adapter write thread started");
NOTICE_LOG_FMT(SERIALINTERFACE, "GC Adapter write thread started");
JNIEnv* env = IDCache::GetEnvForThread();
jmethodID output_func = env->GetStaticMethodID(s_adapter_class, "Output", "([B)I");
@ -108,7 +108,7 @@ static void Write()
// Netplay sends invalid data which results in size = 0x00. Ignore it.
if (size != write_size && size != 0x00)
{
ERROR_LOG(SERIALINTERFACE, "error writing rumble (size: %d)", size);
ERROR_LOG_FMT(SERIALINTERFACE, "error writing rumble (size: {})", size);
Reset();
}
}
@ -116,13 +116,13 @@ static void Write()
Common::YieldCPU();
}
NOTICE_LOG(SERIALINTERFACE, "GC Adapter write thread stopped");
NOTICE_LOG_FMT(SERIALINTERFACE, "GC Adapter write thread stopped");
}
static void Read()
{
Common::SetCurrentThreadName("GC Adapter Read Thread");
NOTICE_LOG(SERIALINTERFACE, "GC Adapter read thread started");
NOTICE_LOG_FMT(SERIALINTERFACE, "GC Adapter read thread started");
bool first_read = true;
JNIEnv* env = IDCache::GetEnvForThread();
@ -179,7 +179,7 @@ static void Read()
s_fd = 0;
s_detected = false;
NOTICE_LOG(SERIALINTERFACE, "GC Adapter read thread stopped");
NOTICE_LOG_FMT(SERIALINTERFACE, "GC Adapter read thread stopped");
}
void Init()
@ -229,7 +229,7 @@ static void Reset()
s_detected = false;
s_fd = 0;
NOTICE_LOG(SERIALINTERFACE, "GC Adapter detached");
NOTICE_LOG_FMT(SERIALINTERFACE, "GC Adapter detached");
}
void Shutdown()
@ -270,7 +270,7 @@ GCPadStatus Input(int chan)
GCPadStatus pad = {};
if (payload_size != controller_payload_copy.size())
{
ERROR_LOG(SERIALINTERFACE, "error reading payload (size: %d, type: %02x)", payload_size,
ERROR_LOG_FMT(SERIALINTERFACE, "error reading payload (size: {}, type: {:02x})", payload_size,
controller_payload_copy[0]);
Reset();
}
@ -281,7 +281,7 @@ GCPadStatus Input(int chan)
if (type != ControllerTypes::CONTROLLER_NONE &&
s_controller_type[chan] == ControllerTypes::CONTROLLER_NONE)
{
ERROR_LOG(SERIALINTERFACE, "New device connected to Port %d of Type: %02x", chan + 1,
ERROR_LOG_FMT(SERIALINTERFACE, "New device connected to Port {} of Type: {:02x}", chan + 1,
controller_payload_copy[1 + (9 * chan)]);
get_origin = true;
}