diff --git a/stratosphere/dmnt/source/dmnt_hid.cpp b/stratosphere/dmnt/source/dmnt_hid.cpp index 46c9eee24..8dd34c672 100644 --- a/stratosphere/dmnt/source/dmnt_hid.cpp +++ b/stratosphere/dmnt/source/dmnt_hid.cpp @@ -16,17 +16,17 @@ #include #include +#include #include "dmnt_hid.hpp" +static HosMutex g_hid_keys_down_lock; + Result HidManagement::GetKeysDown(u64 *keys) { - if (R_FAILED(hidInitialize())) { - return MAKERESULT(Module_Libnx, LibnxError_InitFail_HID); - } + std::scoped_lock lk(g_hid_keys_down_lock); hidScanInput(); *keys = hidKeysDown(CONTROLLER_P1_AUTO); - hidExit(); return 0x0; } \ No newline at end of file diff --git a/stratosphere/dmnt/source/dmnt_main.cpp b/stratosphere/dmnt/source/dmnt_main.cpp index 2eaf1dbb5..5976dd2f4 100644 --- a/stratosphere/dmnt/source/dmnt_main.cpp +++ b/stratosphere/dmnt/source/dmnt_main.cpp @@ -99,6 +99,11 @@ void __appInit(void) { fatalSimple(rc); } + rc = hidInitialize(); + if (R_FAILED(rc)) { + fatalSimple(rc); + } + rc = fsInitialize(); if (R_FAILED(rc)) { fatalSimple(rc); @@ -116,6 +121,7 @@ void __appExit(void) { /* Cleanup services. */ fsdevUnmountAll(); fsExit(); + hidExit(); setExit(); lrExit(); nsdevExit();