From 21971f3a5d38cc697829af69af1c0655a3f563f5 Mon Sep 17 00:00:00 2001 From: Squall Leonhart Date: Mon, 25 Sep 2023 23:18:33 +1000 Subject: [PATCH] Catch exception in Nsyshid on Windows and log it in logDebug This keeps Cemu from crashing when nsyshid's logging encounters an error on Windows and prints the type of exception encountered to the log. --- src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp index 520a0d319..e85b78d16 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp +++ b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp @@ -446,8 +446,17 @@ namespace nsyshid::backend::windows { sprintf(debugOutput + i * 3, "%02x ", data[i]); } - fmt::print("{} Data: {}\n", prefix, debugOutput); - cemuLog_logDebug(LogType::Force, "[{}] Data: {}", prefix, debugOutput); + + try + { + fmt::print("{} Data: {}\n", prefix, debugOutput); + cemuLog_logDebug(LogType::Force, "[{}] Data: {}", prefix, debugOutput); + } catch (const std::exception& e) + { + fmt::print("Error while logging: {}\n", e.what()); + cemuLog_logDebug(LogType::Force, "Error while logging: {}", e.what()); + + } } } // namespace nsyshid::backend::windows