fs.mitm: Fix HID usage (closes #292)

This commit is contained in:
Michael Scire 2018-12-10 19:30:59 -08:00
parent 84c776fa6b
commit a9a71fbeed
2 changed files with 6 additions and 3 deletions

View file

@ -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;
}

View file

@ -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);