From bcc0f86aa34dc4a8fb61d3365a53fd3588179f15 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Thu, 20 Aug 2020 13:28:10 -0400 Subject: [PATCH] hidbus/ringcon: Fixed cleanup, this also fixed a crash. --- nx/source/runtime/ringcon.c | 1 + nx/source/services/hidbus.c | 1 + 2 files changed, 2 insertions(+) diff --git a/nx/source/runtime/ringcon.c b/nx/source/runtime/ringcon.c index 6cf85849..8a99f92d 100644 --- a/nx/source/runtime/ringcon.c +++ b/nx/source/runtime/ringcon.c @@ -95,6 +95,7 @@ Result ringconCreate(RingCon *c, HidControllerID id) { void ringconClose(RingCon *c) { if (c->bus_initialized) { + c->bus_initialized = false; // Official sw uses hidbusDisableJoyPollingReceiveMode here, but that's redundant since hidbusEnableExternalDevice with flag=false uses that automatically. hidbusEnableExternalDevice(c->handle, false, 0x20); hidbusFinalize(c->handle); diff --git a/nx/source/services/hidbus.c b/nx/source/services/hidbus.c index c74bb568..25459cab 100644 --- a/nx/source/services/hidbus.c +++ b/nx/source/services/hidbus.c @@ -279,6 +279,7 @@ Result hidbusFinalize(HidbusBusHandle handle) { if (R_SUCCEEDED(rc)) rc = _hidbusInBusHandleResIdNoOut(&srv, handle, 4); // Finalize eventClose(&entry->event); + memset(&entry->handle, 0, sizeof(entry->handle)); _hidbusSharedmemExit(); }