From 42f14cd74ccdc9135e12fa8cfb31d20e88e4b234 Mon Sep 17 00:00:00 2001 From: cathery Date: Mon, 2 Mar 2020 18:23:41 +0300 Subject: [PATCH] Minor fixes to config handler Added Enable and Disable functions the thread running bool is now properly set to false upon disabling conifg Enable now returns early if the timer was already created CheckForFileChanges is called once when initializing --- source/Sysmodule/source/config_handler.cpp | 19 +++++++++++++++++-- source/Sysmodule/source/config_handler.h | 3 +++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/source/Sysmodule/source/config_handler.cpp b/source/Sysmodule/source/config_handler.cpp index 922e538..fe281d9 100644 --- a/source/Sysmodule/source/config_handler.cpp +++ b/source/Sysmodule/source/config_handler.cpp @@ -181,6 +181,7 @@ namespace syscon::config void ConfigChangedCheckThreadFunc(void *arg) { + WriteToLog("Starting config check thread!"); do { if (R_SUCCEEDED(waitSingle(filecheckTimerWaiter, 0))) { @@ -239,6 +240,7 @@ namespace syscon::config else WriteToLog("Failed to read from dualshock 4 config!"); } + bool CheckForFileChanges() { static u64 globalConfigLastModified; @@ -305,15 +307,28 @@ namespace syscon::config Result Initialize() { config::LoadAllConfigs(); + config::CheckForFileChanges(); utimerCreate(&filecheckTimer, 1e+9L, TimerType_Repeating); + return Enable(); + } + + void Exit() + { + Disable(); + } + + Result Enable() + { + if (filecheckTimer.started) + return 1; utimerStart(&filecheckTimer); is_config_changed_check_thread_running = true; return g_config_changed_check_thread.Start().GetValue(); } - void Exit() + void Disable() { - is_config_changed_check_thread_running = true; + is_config_changed_check_thread_running = false; utimerStop(&filecheckTimer); g_config_changed_check_thread.CancelSynchronization(); g_config_changed_check_thread.Join(); diff --git a/source/Sysmodule/source/config_handler.h b/source/Sysmodule/source/config_handler.h index 438f4a5..0e43792 100644 --- a/source/Sysmodule/source/config_handler.h +++ b/source/Sysmodule/source/config_handler.h @@ -28,4 +28,7 @@ namespace syscon::config Result Initialize(); void Exit(); + + Result Enable(); + void Disable(); }; \ No newline at end of file