mirror of
https://github.com/cathery/sys-con.git
synced 2024-10-04 13:29:43 +00:00
Add LOG macro
This commit is contained in:
parent
773f741d62
commit
f8b472fda9
@ -176,14 +176,14 @@ namespace syscon::config
|
|||||||
|
|
||||||
void ConfigChangedCheckThreadFunc(void *arg)
|
void ConfigChangedCheckThreadFunc(void *arg)
|
||||||
{
|
{
|
||||||
WriteToLog("Starting config check thread!");
|
LOG("Starting config check thread!");
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (R_SUCCEEDED(waitSingle(filecheckTimerWaiter, UINT64_MAX)))
|
if (R_SUCCEEDED(waitSingle(filecheckTimerWaiter, UINT64_MAX)))
|
||||||
{
|
{
|
||||||
if (config::CheckForFileChanges())
|
if (config::CheckForFileChanges())
|
||||||
{
|
{
|
||||||
WriteToLog("File check succeeded! Loading configs...");
|
LOG("File check succeeded! Loading configs...");
|
||||||
config::LoadAllConfigs();
|
config::LoadAllConfigs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,19 +203,19 @@ namespace syscon::config
|
|||||||
LoadGlobalConfig(tempGlobalConfig);
|
LoadGlobalConfig(tempGlobalConfig);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
WriteToLog("Failed to read from global config!");
|
LOG("Failed to read from global config!");
|
||||||
|
|
||||||
if (R_SUCCEEDED(ReadFromConfig(XBOXCONFIG)))
|
if (R_SUCCEEDED(ReadFromConfig(XBOXCONFIG)))
|
||||||
{
|
{
|
||||||
XboxController::LoadConfig(&tempConfig);
|
XboxController::LoadConfig(&tempConfig);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
WriteToLog("Failed to read from xbox orig config!");
|
LOG("Failed to read from xbox orig config!");
|
||||||
|
|
||||||
if (R_SUCCEEDED(ReadFromConfig(XBOXONECONFIG)))
|
if (R_SUCCEEDED(ReadFromConfig(XBOXONECONFIG)))
|
||||||
XboxOneController::LoadConfig(&tempConfig);
|
XboxOneController::LoadConfig(&tempConfig);
|
||||||
else
|
else
|
||||||
WriteToLog("Failed to read from xbox one config!");
|
LOG("Failed to read from xbox one config!");
|
||||||
|
|
||||||
if (R_SUCCEEDED(ReadFromConfig(XBOX360CONFIG)))
|
if (R_SUCCEEDED(ReadFromConfig(XBOX360CONFIG)))
|
||||||
{
|
{
|
||||||
@ -223,17 +223,17 @@ namespace syscon::config
|
|||||||
Xbox360WirelessController::LoadConfig(&tempConfig);
|
Xbox360WirelessController::LoadConfig(&tempConfig);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
WriteToLog("Failed to read from xbox 360 config!");
|
LOG("Failed to read from xbox 360 config!");
|
||||||
|
|
||||||
if (R_SUCCEEDED(ReadFromConfig(DUALSHOCK3CONFIG)))
|
if (R_SUCCEEDED(ReadFromConfig(DUALSHOCK3CONFIG)))
|
||||||
Dualshock3Controller::LoadConfig(&tempConfig);
|
Dualshock3Controller::LoadConfig(&tempConfig);
|
||||||
else
|
else
|
||||||
WriteToLog("Failed to read from dualshock 3 config!");
|
LOG("Failed to read from dualshock 3 config!");
|
||||||
|
|
||||||
if (R_SUCCEEDED(ReadFromConfig(DUALSHOCK4CONFIG)))
|
if (R_SUCCEEDED(ReadFromConfig(DUALSHOCK4CONFIG)))
|
||||||
Dualshock4Controller::LoadConfig(&tempConfig, tempColor);
|
Dualshock4Controller::LoadConfig(&tempConfig, tempColor);
|
||||||
else
|
else
|
||||||
WriteToLog("Failed to read from dualshock 4 config!");
|
LOG("Failed to read from dualshock 4 config!");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckForFileChanges()
|
bool CheckForFileChanges()
|
||||||
|
@ -28,12 +28,12 @@ namespace syscon::controllers
|
|||||||
if (UseAbstractedPad)
|
if (UseAbstractedPad)
|
||||||
{
|
{
|
||||||
switchHandler = std::make_unique<SwitchAbstractedPadHandler>(std::move(controllerPtr));
|
switchHandler = std::make_unique<SwitchAbstractedPadHandler>(std::move(controllerPtr));
|
||||||
WriteToLog("Inserting controller as abstracted pad");
|
LOG("Inserting controller as abstracted pad");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switchHandler = std::make_unique<SwitchHDLHandler>(std::move(controllerPtr));
|
switchHandler = std::make_unique<SwitchHDLHandler>(std::move(controllerPtr));
|
||||||
WriteToLog("Inserting controller as HDLs");
|
LOG("Inserting controller as HDLs");
|
||||||
}
|
}
|
||||||
|
|
||||||
Result rc = switchHandler->Initialize();
|
Result rc = switchHandler->Initialize();
|
||||||
|
@ -25,7 +25,7 @@ void DiscardOldLogs()
|
|||||||
if (fileSize >= 0x20'000)
|
if (fileSize >= 0x20'000)
|
||||||
{
|
{
|
||||||
fsFsDeleteFile(fs, LOG_PATH);
|
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);
|
vfprintf(fp, fmt, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
fprintf(fp, "\n");
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,3 +15,5 @@ extern "C"
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define LOG(fmt, ...) WriteToLog(fmt "\n", ##__VA_ARGS__)
|
||||||
|
@ -87,7 +87,7 @@ using namespace syscon;
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
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();
|
config::Initialize();
|
||||||
controllers::Initialize();
|
controllers::Initialize();
|
||||||
usb::Initialize();
|
usb::Initialize();
|
||||||
|
@ -52,24 +52,24 @@ namespace syscon::usb
|
|||||||
{
|
{
|
||||||
if (R_SUCCEEDED(eventWait(&g_usbCatchAllEvent, UINT64_MAX)))
|
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);
|
std::scoped_lock usbLock(usbMutex);
|
||||||
if (!controllers::IsAtControllerLimit())
|
if (!controllers::IsAtControllerLimit())
|
||||||
{
|
{
|
||||||
s32 total_entries;
|
s32 total_entries;
|
||||||
if ((total_entries = QueryInterfaces(USB_CLASS_VENDOR_SPEC, 93, 1)) != 0)
|
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)
|
if ((total_entries = QueryInterfaces(USB_CLASS_VENDOR_SPEC, 93, 129)) != 0)
|
||||||
for (int i = 0; i != total_entries; ++i)
|
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)
|
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)
|
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);
|
} while (is_usb_event_thread_running);
|
||||||
@ -81,17 +81,17 @@ namespace syscon::usb
|
|||||||
{
|
{
|
||||||
if (R_SUCCEEDED(eventWait(&g_usbSonyEvent, UINT64_MAX)))
|
if (R_SUCCEEDED(eventWait(&g_usbSonyEvent, UINT64_MAX)))
|
||||||
{
|
{
|
||||||
WriteToLog("Sony event went off");
|
LOG("Sony event went off");
|
||||||
|
|
||||||
std::scoped_lock usbLock(usbMutex);
|
std::scoped_lock usbLock(usbMutex);
|
||||||
if (!controllers::IsAtControllerLimit())
|
if (!controllers::IsAtControllerLimit())
|
||||||
{
|
{
|
||||||
s32 total_entries;
|
s32 total_entries;
|
||||||
if ((QueryVendorProduct(VENDOR_SONY, PRODUCT_DUALSHOCK3) != 0) && (total_entries = QueryInterfaces(USB_CLASS_HID, 0, 0)) != 0)
|
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)
|
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);
|
} while (is_usb_event_thread_running);
|
||||||
@ -104,7 +104,7 @@ namespace syscon::usb
|
|||||||
if (R_SUCCEEDED(eventWait(usbHsGetInterfaceStateChangeEvent(), UINT64_MAX)))
|
if (R_SUCCEEDED(eventWait(usbHsGetInterfaceStateChangeEvent(), UINT64_MAX)))
|
||||||
{
|
{
|
||||||
s32 total_entries;
|
s32 total_entries;
|
||||||
WriteToLog("Interface state was changed");
|
LOG("Interface state was changed");
|
||||||
|
|
||||||
std::scoped_lock usbLock(usbMutex);
|
std::scoped_lock usbLock(usbMutex);
|
||||||
std::scoped_lock controllersLock(controllers::GetScopedLock());
|
std::scoped_lock controllersLock(controllers::GetScopedLock());
|
||||||
@ -133,9 +133,9 @@ namespace syscon::usb
|
|||||||
|
|
||||||
if (!found_flag)
|
if (!found_flag)
|
||||||
{
|
{
|
||||||
WriteToLog("Erasing controller");
|
LOG("Erasing controller");
|
||||||
controllers::Get().erase(it--);
|
controllers::Get().erase(it--);
|
||||||
WriteToLog("Controller erased!");
|
LOG("Controller erased!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user