From a9a71fbeedeb2a98c1a0e8c612b5c73d8bd894d6 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 10 Dec 2018 19:30:59 -0800 Subject: [PATCH] fs.mitm: Fix HID usage (closes #292) --- stratosphere/fs_mitm/source/fsmitm_utils.cpp | 7 +++++-- stratosphere/fs_mitm/source/fsmitm_utils.hpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) 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);