1
0
mirror of https://github.com/cathery/sys-con.git synced 2024-07-03 02:18:43 +00:00

Add LOG macro

This commit is contained in:
cathery 2020-12-07 18:04:05 +03:00
parent 773f741d62
commit f8b472fda9
6 changed files with 25 additions and 24 deletions

View File

@ -176,14 +176,14 @@ namespace syscon::config
void ConfigChangedCheckThreadFunc(void *arg)
{
WriteToLog("Starting config check thread!");
LOG("Starting config check thread!");
do
{
if (R_SUCCEEDED(waitSingle(filecheckTimerWaiter, UINT64_MAX)))
{
if (config::CheckForFileChanges())
{
WriteToLog("File check succeeded! Loading configs...");
LOG("File check succeeded! Loading configs...");
config::LoadAllConfigs();
}
}
@ -203,19 +203,19 @@ namespace syscon::config
LoadGlobalConfig(tempGlobalConfig);
}
else
WriteToLog("Failed to read from global config!");
LOG("Failed to read from global config!");
if (R_SUCCEEDED(ReadFromConfig(XBOXCONFIG)))
{
XboxController::LoadConfig(&tempConfig);
}
else
WriteToLog("Failed to read from xbox orig config!");
LOG("Failed to read from xbox orig config!");
if (R_SUCCEEDED(ReadFromConfig(XBOXONECONFIG)))
XboxOneController::LoadConfig(&tempConfig);
else
WriteToLog("Failed to read from xbox one config!");
LOG("Failed to read from xbox one config!");
if (R_SUCCEEDED(ReadFromConfig(XBOX360CONFIG)))
{
@ -223,17 +223,17 @@ namespace syscon::config
Xbox360WirelessController::LoadConfig(&tempConfig);
}
else
WriteToLog("Failed to read from xbox 360 config!");
LOG("Failed to read from xbox 360 config!");
if (R_SUCCEEDED(ReadFromConfig(DUALSHOCK3CONFIG)))
Dualshock3Controller::LoadConfig(&tempConfig);
else
WriteToLog("Failed to read from dualshock 3 config!");
LOG("Failed to read from dualshock 3 config!");
if (R_SUCCEEDED(ReadFromConfig(DUALSHOCK4CONFIG)))
Dualshock4Controller::LoadConfig(&tempConfig, tempColor);
else
WriteToLog("Failed to read from dualshock 4 config!");
LOG("Failed to read from dualshock 4 config!");
}
bool CheckForFileChanges()

View File

@ -28,12 +28,12 @@ namespace syscon::controllers
if (UseAbstractedPad)
{
switchHandler = std::make_unique<SwitchAbstractedPadHandler>(std::move(controllerPtr));
WriteToLog("Inserting controller as abstracted pad");
LOG("Inserting controller as abstracted pad");
}
else
{
switchHandler = std::make_unique<SwitchHDLHandler>(std::move(controllerPtr));
WriteToLog("Inserting controller as HDLs");
LOG("Inserting controller as HDLs");
}
Result rc = switchHandler->Initialize();

View File

@ -25,7 +25,7 @@ void DiscardOldLogs()
if (fileSize >= 0x20'000)
{
fsFsDeleteFile(fs, LOG_PATH);
WriteToLog("Deleted previous log file");
LOG("Deleted previous log file");
}
}
@ -46,7 +46,6 @@ void WriteToLog(const char *fmt, ...)
vfprintf(fp, fmt, va);
va_end(va);
fprintf(fp, "\n");
fclose(fp);
}

View File

@ -15,3 +15,5 @@ extern "C"
#ifdef __cplusplus
}
#endif
#define LOG(fmt, ...) WriteToLog(fmt "\n", ##__VA_ARGS__)

View File

@ -87,7 +87,7 @@ using namespace syscon;
int main(int argc, char *argv[])
{
WriteToLog("\n\nNew sysmodule session started on version " APP_VERSION);
LOG("\n\nNew sysmodule session started on version " APP_VERSION);
config::Initialize();
controllers::Initialize();
usb::Initialize();

View File

@ -52,24 +52,24 @@ namespace syscon::usb
{
if (R_SUCCEEDED(eventWait(&g_usbCatchAllEvent, UINT64_MAX)))
{
WriteToLog("Catch-all event went off");
LOG("Catch-all event went off");
std::scoped_lock usbLock(usbMutex);
if (!controllers::IsAtControllerLimit())
{
s32 total_entries;
if ((total_entries = QueryInterfaces(USB_CLASS_VENDOR_SPEC, 93, 1)) != 0)
WriteToLog("Initializing Xbox 360 controller: 0x%x", controllers::Insert(std::make_unique<Xbox360Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
LOG("Initializing Xbox 360 controller: 0x%x", controllers::Insert(std::make_unique<Xbox360Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
if ((total_entries = QueryInterfaces(USB_CLASS_VENDOR_SPEC, 93, 129)) != 0)
for (int i = 0; i != total_entries; ++i)
WriteToLog("Initializing Xbox 360 wireless controller: 0x%x", controllers::Insert(std::make_unique<Xbox360WirelessController>(std::make_unique<SwitchUSBDevice>(interfaces + i, 1))));
LOG("Initializing Xbox 360 wireless controller: 0x%x", controllers::Insert(std::make_unique<Xbox360WirelessController>(std::make_unique<SwitchUSBDevice>(interfaces + i, 1))));
if ((total_entries = QueryInterfaces(0x58, 0x42, 0x00)) != 0)
WriteToLog("Initializing Xbox Original controller: 0x%x", controllers::Insert(std::make_unique<XboxController>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
LOG("Initializing Xbox Original controller: 0x%x", controllers::Insert(std::make_unique<XboxController>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
if ((total_entries = QueryInterfaces(USB_CLASS_VENDOR_SPEC, 71, 208)) != 0)
WriteToLog("Initializing Xbox One controller: 0x%x", controllers::Insert(std::make_unique<XboxOneController>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
LOG("Initializing Xbox One controller: 0x%x", controllers::Insert(std::make_unique<XboxOneController>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
}
}
} while (is_usb_event_thread_running);
@ -81,17 +81,17 @@ namespace syscon::usb
{
if (R_SUCCEEDED(eventWait(&g_usbSonyEvent, UINT64_MAX)))
{
WriteToLog("Sony event went off");
LOG("Sony event went off");
std::scoped_lock usbLock(usbMutex);
if (!controllers::IsAtControllerLimit())
{
s32 total_entries;
if ((QueryVendorProduct(VENDOR_SONY, PRODUCT_DUALSHOCK3) != 0) && (total_entries = QueryInterfaces(USB_CLASS_HID, 0, 0)) != 0)
WriteToLog("Initializing Dualshock 3 controller: 0x%x", controllers::Insert(std::make_unique<Dualshock3Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
LOG("Initializing Dualshock 3 controller: 0x%x", controllers::Insert(std::make_unique<Dualshock3Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
else if ((QueryVendorProduct(VENDOR_SONY, PRODUCT_DUALSHOCK4_1X) != 0 || QueryVendorProduct(VENDOR_SONY, PRODUCT_DUALSHOCK4_2X) != 0) && (total_entries = QueryInterfaces(USB_CLASS_HID, 0, 0)) != 0)
WriteToLog("Initializing Dualshock 4 controller: 0x%x", controllers::Insert(std::make_unique<Dualshock4Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
LOG("Initializing Dualshock 4 controller: 0x%x", controllers::Insert(std::make_unique<Dualshock4Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
}
}
} while (is_usb_event_thread_running);
@ -104,7 +104,7 @@ namespace syscon::usb
if (R_SUCCEEDED(eventWait(usbHsGetInterfaceStateChangeEvent(), UINT64_MAX)))
{
s32 total_entries;
WriteToLog("Interface state was changed");
LOG("Interface state was changed");
std::scoped_lock usbLock(usbMutex);
std::scoped_lock controllersLock(controllers::GetScopedLock());
@ -133,9 +133,9 @@ namespace syscon::usb
if (!found_flag)
{
WriteToLog("Erasing controller");
LOG("Erasing controller");
controllers::Get().erase(it--);
WriteToLog("Controller erased!");
LOG("Controller erased!");
}
}
}