diff --git a/stratosphere/fs_mitm/source/fsmitm_utils.cpp b/stratosphere/fs_mitm/source/fsmitm_utils.cpp index 2151e22ff..39d8ce1f4 100644 --- a/stratosphere/fs_mitm/source/fsmitm_utils.cpp +++ b/stratosphere/fs_mitm/source/fsmitm_utils.cpp @@ -191,6 +191,8 @@ void Utils::InitializeHidThreadFunc(void *args) { g_has_hid_session = true; + hidExit(); + svcExitThread(); } @@ -198,7 +200,7 @@ bool Utils::IsSdInitialized() { return g_has_initialized; } -bool Utils::IsHidInitialized() { +bool Utils::IsHidAvailable() { return g_has_hid_session; } @@ -410,13 +412,14 @@ bool Utils::HasSdDisableMitMFlag(u64 tid) { } Result Utils::GetKeysDown(u64 *keys) { - if (!Utils::IsHidInitialized()) { + if (!Utils::IsHidAvailable() || R_FAILED(hidInitialize())) { return MAKERESULT(Module_Libnx, LibnxError_InitFail_HID); } hidScanInput(); *keys = hidKeysDown(CONTROLLER_P1_AUTO); + hidExit(); return 0x0; } diff --git a/stratosphere/fs_mitm/source/fsmitm_utils.hpp b/stratosphere/fs_mitm/source/fsmitm_utils.hpp index 0811c1f7e..856748c4d 100644 --- a/stratosphere/fs_mitm/source/fsmitm_utils.hpp +++ b/stratosphere/fs_mitm/source/fsmitm_utils.hpp @@ -67,7 +67,7 @@ class Utils { static bool HasSdDisableMitMFlag(u64 tid); - static bool IsHidInitialized(); + static bool IsHidAvailable(); static void InitializeHidThreadFunc(void *args); static Result GetKeysDown(u64 *keys); static bool HasOverrideButton(u64 tid);