diff options
| author | Léo Lam <leo@leolam.fr> | 2020-10-23 19:59:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-23 19:59:22 +0200 |
| commit | ce6eda7c717c1dad7d79b91ec421c196ac969357 (patch) | |
| tree | 873d58f4d200391135106b5e459b8d45cf47332c /Source/Core/InputCommon/ControllerInterface | |
| parent | 87e4a0785addc5c0e4eb04cb7cf8d93c551d34fc (diff) | |
| parent | a5e1415e74ce5b6b2a339256aa3e97748a3a2484 (diff) | |
Merge pull request #9184 from lioncash/inputlog
InputCommon: Migrate logging over to fmt
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
11 files changed, 120 insertions, 98 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index 342869a69b..eabc2cd0f1 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -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; diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp index 2fc0e1b972..d508de613a 100644 --- a/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp +++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp @@ -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; } diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp index 633950cc2d..67fd33186b 100644 --- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp +++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp @@ -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(); diff --git a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp index 371db4219c..200b904b17 100644 --- a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp +++ b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp @@ -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 diff --git a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPProto.h b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPProto.h index 97b453a68a..582b483555 100644 --- a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPProto.h +++ b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPProto.h @@ -242,15 +242,16 @@ 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", - crc32_in_header, crc32_calculated); + NOTICE_LOG_FMT( + SERIALINTERFACE, + "DualShockUDPClient Received message with bad CRC in header: got {:08x}, expected {:08x}", + crc32_in_header, crc32_calculated); return std::nullopt; } if (m_message.header.protocol_version > CEMUHOOK_PROTOCOL_VERSION) diff --git a/Source/Core/InputCommon/ControllerInterface/OSX/OSX.mm b/Source/Core/InputCommon/ControllerInterface/OSX/OSX.mm index 37b1fa8cfd..de878b6a3e 100644 --- a/Source/Core/InputCommon/ControllerInterface/OSX/OSX.mm +++ b/Source/Core/InputCommon/ControllerInterface/OSX/OSX.mm @@ -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"); }); } diff --git a/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.mm b/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.mm index 3b59d5b2ec..39794426a8 100644 --- a/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.mm +++ b/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.mm @@ -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; } diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp index 2d2d256c2a..e232fd6ee7 100644 --- a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp +++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp @@ -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; diff --git a/Source/Core/InputCommon/ControllerInterface/Wiimote/Wiimote.cpp b/Source/Core/InputCommon/ControllerInterface/Wiimote/Wiimote.cpp index 2a95fc0a57..2a11904550 100644 --- a/Source/Core/InputCommon/ControllerInterface/Wiimote/Wiimote.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Wiimote/Wiimote.cpp @@ -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; diff --git a/Source/Core/InputCommon/ControllerInterface/Win32/Win32.cpp b/Source/Core/InputCommon/ControllerInterface/Win32/Win32.cpp index 76124a97e8..67a31a062a 100644 --- a/Source/Core/InputCommon/ControllerInterface/Win32/Win32.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Win32/Win32.cpp @@ -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); diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index 77f796b22f..61b6a1e46b 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -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() |
