diff --git a/btdrv-mitm/source/bluetooth/bluetooth_hid_report.cpp b/btdrv-mitm/source/bluetooth/bluetooth_hid_report.cpp index 6f70393..4f5c2f5 100644 --- a/btdrv-mitm/source/bluetooth/bluetooth_hid_report.cpp +++ b/btdrv-mitm/source/bluetooth/bluetooth_hid_report.cpp @@ -95,6 +95,9 @@ namespace ams::bluetooth::hid::report { void Finalize(void) { os::DestroyThread(&g_eventHandlerThread); + //if (hos::GetVersion() < hos::Version_7_0_0) + //delete g_fakeBuffer; + os::DestroySystemEvent(&g_btHidReportSystemEventUser); os::DestroySystemEvent(&g_btHidReportSystemEventFwd); @@ -110,6 +113,27 @@ namespace ams::bluetooth::hid::report { return ams::ResultSuccess(); } + Result InitializeReportBuffer(void) { + BTDRV_LOG_FMT("btdrv-mitm: InitializeReportBuffer"); + + // Todo: maybe just create shared memory for all fw? + if (hos::GetVersion() < hos::Version_7_0_0) { + g_fakeBuffer = new CircularBuffer(); + } + else { + R_TRY(shmemCreate(&g_fakeBtShmem, BLUETOOTH_SHAREDMEM_SIZE, Perm_Rw, Perm_Rw)); + R_TRY(shmemMap(&g_fakeBtShmem)); + g_fakeBuffer = reinterpret_cast(shmemGetAddr(&g_fakeBtShmem)); + } + + g_fakeBuffer->Initialize("HID Report"); + g_fakeBuffer->type = CircularBufferType_HidReport; + g_fakeBuffer->_unk3 = 1; + + return ams::ResultSuccess(); + } + + /* Result InitializeFakeSharedMemory(void) { R_TRY(shmemCreate(&g_fakeBtShmem, BLUETOOTH_SHAREDMEM_SIZE, Perm_Rw, Perm_Rw)); R_TRY(shmemMap(&g_fakeBtShmem)); diff --git a/btdrv-mitm/source/bluetooth/bluetooth_hid_report.hpp b/btdrv-mitm/source/bluetooth/bluetooth_hid_report.hpp index efedc14..fda055b 100644 --- a/btdrv-mitm/source/bluetooth/bluetooth_hid_report.hpp +++ b/btdrv-mitm/source/bluetooth/bluetooth_hid_report.hpp @@ -18,7 +18,8 @@ namespace ams::bluetooth::hid::report { void Finalize(void); Result MapRemoteSharedMemory(Handle handle); - Result InitializeFakeSharedMemory(void); + //Result InitializeFakeSharedMemory(void); + Result InitializeReportBuffer(void); Result WriteFakeHidData(const Address *address, const HidData *data); diff --git a/btdrv-mitm/source/btdrv_mitm_service.cpp b/btdrv-mitm/source/btdrv_mitm_service.cpp index a79e929..44fc86c 100644 --- a/btdrv-mitm/source/btdrv_mitm_service.cpp +++ b/btdrv-mitm/source/btdrv_mitm_service.cpp @@ -18,9 +18,10 @@ namespace ams::mitm::btdrv { Handle handle = INVALID_HANDLE; R_TRY(btdrvInitializeBluetoothFwd(this->forward_service.get(), &handle)); R_TRY(bluetooth::core::Initialize(handle)); + R_TRY(bluetooth::hid::report::InitializeReportBuffer()); - if (hos::GetVersion() >= hos::Version_7_0_0) - R_TRY(bluetooth::hid::report::InitializeFakeSharedMemory()); + //if (hos::GetVersion() >= hos::Version_7_0_0) + //R_TRY(bluetooth::hid::report::InitializeFakeSharedMemory()); out_handle.SetValue(os::GetReadableHandleOfSystemEvent(bluetooth::core::GetForwardEvent())); } else {