From d375ed00e2617fcdbdb7050342160158ada77508 Mon Sep 17 00:00:00 2001 From: ndeadly <24677491+ndeadly@users.noreply.github.com> Date: Thu, 6 Aug 2020 02:25:56 +0200 Subject: [PATCH] btdrv-mitm: fix for xbox one controller disconnections --- btdrv-mitm/source/bluetooth/bluetooth_hid.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/btdrv-mitm/source/bluetooth/bluetooth_hid.cpp b/btdrv-mitm/source/bluetooth/bluetooth_hid.cpp index 3e75555..24c0bb2 100644 --- a/btdrv-mitm/source/bluetooth/bluetooth_hid.cpp +++ b/btdrv-mitm/source/bluetooth/bluetooth_hid.cpp @@ -97,12 +97,6 @@ namespace ams::bluetooth::hid { BTDRV_LOG_FMT("[%02d] HID Event", g_currentEventType); - os::SignalSystemEvent(&g_btHidSystemEventFwd); - os::WaitEvent(&g_dataReadEvent); - - if (g_btHidSystemEventUser.state) - os::SignalSystemEvent(&g_btHidSystemEventUser); - auto eventData = reinterpret_cast(g_eventDataBuffer); switch (g_currentEventType) { @@ -110,11 +104,22 @@ namespace ams::bluetooth::hid { case HidEvent_ConnectionState: handleConnectionStateEvent(eventData); break; - + case HidEvent_Unknown07: + // Fix for xbox one disconnection. Don't know what this value is for, but it appears to be 0 for other controllers + // Todo: check bd address is xbox controller + g_eventDataBuffer[4] = 0; + break; default: + BTDRV_LOG_DATA(g_eventDataBuffer, sizeof(g_eventDataBuffer)); break; } + os::SignalSystemEvent(&g_btHidSystemEventFwd); + os::WaitEvent(&g_dataReadEvent); + + if (g_btHidSystemEventUser.state) + os::SignalSystemEvent(&g_btHidSystemEventUser); + } }