From f7a7f784686bfdc96cef6af2aa7bf43eacc14fc3 Mon Sep 17 00:00:00 2001 From: ndeadly <24677491+ndeadly@users.noreply.github.com> Date: Fri, 11 Sep 2020 22:03:41 +0200 Subject: [PATCH] bluetooth-mitm: get booting on console again --- bluetooth-mitm/bluetooth-mitm.json | 6 +-- bluetooth-mitm/source/bluetoothmitm_main.cpp | 11 ++-- .../btdrv_mitm/bluetooth/bluetooth_core.cpp | 2 +- .../btdrv_mitm/bluetooth/bluetooth_hid.cpp | 2 +- .../bluetooth/bluetooth_hid_report.cpp | 2 +- .../btdrv_mitm/bluetooth/bluetooth_types.hpp | 26 ---------- .../source/btdrv_mitm/btdrv_mitm_service.cpp | 2 +- .../source/btdrv_mitm/btdrvmitm_module.cpp | 24 +++++---- .../source/btdrv_mitm/btdrvmitm_module.hpp | 3 +- .../source/btm_mitm/btm_mitm_service.cpp | 6 +-- .../source/btm_mitm/btm_mitm_service.hpp | 2 +- .../source/btm_mitm/btmmitm_module.cpp | 25 ++++----- .../source/btm_mitm/btmmitm_module.hpp | 2 +- .../emulated_switch_controller.cpp | 52 +++++++++---------- .../source/controllers/switch_controller.hpp | 30 ++++++++++- 15 files changed, 100 insertions(+), 95 deletions(-) diff --git a/bluetooth-mitm/bluetooth-mitm.json b/bluetooth-mitm/bluetooth-mitm.json index af29bb4..ae4c731 100644 --- a/bluetooth-mitm/bluetooth-mitm.json +++ b/bluetooth-mitm/bluetooth-mitm.json @@ -3,8 +3,8 @@ "title_id": "0x010000000000bd00", "title_id_range_min": "0x010000000000bd00", "title_id_range_max": "0x010000000000bd00", - "main_thread_stack_size": "0x4000", - "main_thread_priority": 42, + "main_thread_stack_size": "0x10000", + "main_thread_priority": 22, "default_cpu_id": 3, "process_category": 1, "is_retail": true, @@ -25,7 +25,7 @@ "type": "kernel_flags", "value": { "highest_thread_priority": 63, - "lowest_thread_priority": 24, + "lowest_thread_priority": 12, "lowest_cpu_id": 3, "highest_cpu_id": 3 } diff --git a/bluetooth-mitm/source/bluetoothmitm_main.cpp b/bluetooth-mitm/source/bluetoothmitm_main.cpp index 395018b..63dd03d 100644 --- a/bluetooth-mitm/source/bluetoothmitm_main.cpp +++ b/bluetooth-mitm/source/bluetoothmitm_main.cpp @@ -26,7 +26,7 @@ extern "C" { u32 __nx_applet_type = AppletType_None; u32 __nx_fs_num_sessions = 1; - #define INNER_HEAP_SIZE 0x10000 + #define INNER_HEAP_SIZE 0x80000 size_t nx_inner_heap_size = INNER_HEAP_SIZE; char nx_inner_heap[INNER_HEAP_SIZE]; @@ -92,9 +92,10 @@ void __libnx_exception_handler(ThreadExceptionDump* ctx) { ams::CrashHandler(ctx); } -void LaunchModules(void) { - ams::mitm::btdrv::Launch(); - ams::mitm::btm::Launch(); +ams::Result LaunchModules(void) { + R_TRY(ams::mitm::btdrv::Launch()); + R_TRY(ams::mitm::btm::Launch()); + return ams::ResultSuccess(); } void WaitModules(void) { @@ -103,7 +104,7 @@ void WaitModules(void) { } int main(int argc, char **argv) { - LaunchModules(); + R_ABORT_UNLESS(LaunchModules()); WaitModules(); return 0; diff --git a/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_core.cpp b/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_core.cpp index 6d584c5..5dfd003 100644 --- a/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_core.cpp +++ b/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_core.cpp @@ -16,7 +16,7 @@ */ #include "bluetooth_core.hpp" #include "../btdrv_mitm_flags.hpp" -#include "../controllers/controller_management.hpp" +#include "../../controllers/controller_management.hpp" #include #include #include diff --git a/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_hid.cpp b/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_hid.cpp index f6acb8b..1183954 100644 --- a/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_hid.cpp +++ b/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_hid.cpp @@ -16,7 +16,7 @@ */ #include "bluetooth_hid.hpp" #include "../btdrv_mitm_flags.hpp" -#include "../controllers/controller_management.hpp" +#include "../../controllers/controller_management.hpp" #include #include #include diff --git a/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_hid_report.cpp b/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_hid_report.cpp index a93ab75..66fef22 100644 --- a/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_hid_report.cpp +++ b/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_hid_report.cpp @@ -18,7 +18,7 @@ #include "bluetooth_circular_buffer.hpp" #include "../btdrv_shim.h" #include "../btdrv_mitm_flags.hpp" -#include "../controllers/controller_management.hpp" +#include "../../controllers/controller_management.hpp" #include #include #include diff --git a/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_types.hpp b/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_types.hpp index 048c9d0..edb5d46 100644 --- a/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_types.hpp +++ b/bluetooth-mitm/source/btdrv_mitm/bluetooth/bluetooth_types.hpp @@ -20,32 +20,6 @@ namespace ams::bluetooth { - enum SubCmdType : u8 { - SubCmd_GetControllerState = 0x00, - SubCmd_ManualPair = 0x01, - SubCmd_RequestDeviceInfo = 0x02, - SubCmd_SetInputReportMode = 0x03, - SubCmd_TriggersElapsedTime = 0x04, - SubCmd_SetHciState = 0x06, - SubCmd_ResetPairingInfo = 0x07, - SubCmd_SetShipPowerState = 0x08, - SubCmd_SpiFlashRead = 0x10, - SubCmd_SpiFlashWrite = 0x11, - SubCmd_SpiSectorErase = 0x12, - SubCmd_ResetMcu = 0x20, - SubCmd_SetMcuConfig = 0x21, - SubCmd_SetMcuState = 0x22, - SubCmd_SetPlayerLeds = 0x30, - SubCmd_GetPlayerLeds = 0x31, - SubCmd_SetHomeLed = 0x38, - SubCmd_EnableImu = 0x40, - SubCmd_SetImuSensitivity = 0x41, - SubCmd_WriteImuRegisters = 0x42, - SubCmd_ReadImuRegisters = 0x43, - SubCmd_EnableVibration = 0x48, - SubCmd_GetRegulatedVoltage = 0x50, - }; - typedef BluetoothEventType EventType; typedef BluetoothHidEventType HidEventType; typedef BluetoothBleEventType BleEventType; diff --git a/bluetooth-mitm/source/btdrv_mitm/btdrv_mitm_service.cpp b/bluetooth-mitm/source/btdrv_mitm/btdrv_mitm_service.cpp index f04edbc..ebfa302 100644 --- a/bluetooth-mitm/source/btdrv_mitm/btdrv_mitm_service.cpp +++ b/bluetooth-mitm/source/btdrv_mitm/btdrv_mitm_service.cpp @@ -18,7 +18,7 @@ #include "btdrv_mitm_flags.hpp" #include "btdrv_shim.h" #include "bluetooth/bluetooth_events.hpp" -#include "controllers/controller_management.hpp" +#include "../controllers/controller_management.hpp" #include #include diff --git a/bluetooth-mitm/source/btdrv_mitm/btdrvmitm_module.cpp b/bluetooth-mitm/source/btdrv_mitm/btdrvmitm_module.cpp index 940d5bc..1a6adc5 100644 --- a/bluetooth-mitm/source/btdrv_mitm/btdrvmitm_module.cpp +++ b/bluetooth-mitm/source/btdrv_mitm/btdrvmitm_module.cpp @@ -39,26 +39,28 @@ namespace ams::mitm::btdrv { alignas(os::ThreadStackAlignment) u8 g_btdrv_mitm_thread_stack[0x4000]; constexpr s32 g_btdrv_mitm_thread_priority = 16; + void BtdrvMitmThreadFunction(void *arg) { + R_ABORT_UNLESS(bluetooth::events::Initialize()); + + auto server_manager = std::make_unique>(); + R_ABORT_UNLESS((server_manager->RegisterMitmServer(MitmServiceName))); + server_manager->LoopProcess(); + } + } - void BtdrvMitmThreadFunction(void *arg) { - R_ABORT_UNLESS(bluetooth::events::Initialize()); - - auto server_manager = std::make_unique>(); - R_ABORT_UNLESS((server_manager->RegisterMitmServer(MitmServiceName))); - server_manager->LoopProcess(); - } - - void Launch(void) { - os::CreateThread(&g_btdrv_mitm_thread, + Result Launch(void) { + R_TRY(os::CreateThread(&g_btdrv_mitm_thread, BtdrvMitmThreadFunction, nullptr, g_btdrv_mitm_thread_stack, sizeof(g_btdrv_mitm_thread_stack), g_btdrv_mitm_thread_priority - ); + )); os::StartThread(&g_btdrv_mitm_thread); + + return ams::ResultSuccess(); } void WaitFinished(void) { diff --git a/bluetooth-mitm/source/btdrv_mitm/btdrvmitm_module.hpp b/bluetooth-mitm/source/btdrv_mitm/btdrvmitm_module.hpp index 1629500..ea5cf12 100644 --- a/bluetooth-mitm/source/btdrv_mitm/btdrvmitm_module.hpp +++ b/bluetooth-mitm/source/btdrv_mitm/btdrvmitm_module.hpp @@ -15,10 +15,11 @@ * along with this program. If not, see . */ #pragma once +#include namespace ams::mitm::btdrv { - void Launch(void); + Result Launch(void); void WaitFinished(void); } diff --git a/bluetooth-mitm/source/btm_mitm/btm_mitm_service.cpp b/bluetooth-mitm/source/btm_mitm/btm_mitm_service.cpp index f831dc5..760fe4b 100644 --- a/bluetooth-mitm/source/btm_mitm/btm_mitm_service.cpp +++ b/bluetooth-mitm/source/btm_mitm/btm_mitm_service.cpp @@ -16,7 +16,7 @@ */ #include "btm_mitm_service.hpp" #include "btm_shim.h" -#include "../btdrv_mitm/controllers/controller_management.hpp" +#include "../controllers/controller_management.hpp" #include namespace ams::mitm::btm { @@ -26,7 +26,7 @@ namespace ams::mitm::btm { void RenameConnectedDevices(BtmConnectedDevice devices[], size_t count) { for (unsigned int i = 0; i < count; ++i) { auto device = &devices[i]; - if (!IsOfficialSwitchControllerName(device->name, sizeof(device->name))) { + if (!controller::IsOfficialSwitchControllerName(device->name, sizeof(device->name))) { std::strncpy(device->name, controller::pro_controller_name, sizeof(device->name) - 1); } } @@ -68,7 +68,7 @@ namespace ams::mitm::btm { for (unsigned int i = 0; i < device_info->count; ++i) { auto device = &device_info->devices[i]; - if (!IsOfficialSwitchControllerName(device->name, sizeof(device->name))) { + if (!controller::IsOfficialSwitchControllerName(device->name, sizeof(device->name))) { std::strncpy(device->name, controller::pro_controller_name, sizeof(device->name) - 1); } } diff --git a/bluetooth-mitm/source/btm_mitm/btm_mitm_service.hpp b/bluetooth-mitm/source/btm_mitm/btm_mitm_service.hpp index ae565cf..ba4ce27 100644 --- a/bluetooth-mitm/source/btm_mitm/btm_mitm_service.hpp +++ b/bluetooth-mitm/source/btm_mitm/btm_mitm_service.hpp @@ -16,7 +16,7 @@ */ #pragma once #include -#include "btm_types.hpp" +#include "btm/btm_types.hpp" namespace ams::mitm::btm { diff --git a/bluetooth-mitm/source/btm_mitm/btmmitm_module.cpp b/bluetooth-mitm/source/btm_mitm/btmmitm_module.cpp index 5c3151c..f42766e 100644 --- a/bluetooth-mitm/source/btm_mitm/btmmitm_module.cpp +++ b/bluetooth-mitm/source/btm_mitm/btmmitm_module.cpp @@ -32,35 +32,36 @@ namespace ams::mitm::btm { }; constexpr size_t MaxServers = 1; - constexpr size_t MaxSessions = 8; + constexpr size_t MaxSessions = 6; os::ThreadType g_btm_mitm_thread; alignas(os::ThreadStackAlignment) u8 g_btm_mitm_thread_stack[0x4000]; - constexpr s32 g_btm_mitm_thread_priority = 36; + constexpr s32 g_btm_mitm_thread_priority = 18; + + void BtmMitmThreadFunction(void *arg) { + auto server_manager = std::make_unique>(); + R_ABORT_UNLESS((server_manager->RegisterMitmServer(MitmServiceName))); + server_manager->LoopProcess(); + } } - void BtmMitmThreadFunction(void *arg) { - auto server_manager = std::make_unique>(); - R_ABORT_UNLESS((server_manager->RegisterMitmServer(MitmServiceName))); - server_manager->LoopProcess(); - } - - void Launch(void) { - os::CreateThread(&g_btm_mitm_thread, + Result Launch(void) { + R_TRY(os::CreateThread(&g_btm_mitm_thread, BtmMitmThreadFunction, nullptr, g_btm_mitm_thread_stack, sizeof(g_btm_mitm_thread_stack), g_btm_mitm_thread_priority - ); + )); os::StartThread(&g_btm_mitm_thread); + + return ams::ResultSuccess(); } void WaitFinished(void) { os::WaitThread(&g_btm_mitm_thread); } - } diff --git a/bluetooth-mitm/source/btm_mitm/btmmitm_module.hpp b/bluetooth-mitm/source/btm_mitm/btmmitm_module.hpp index 5f164e0..fb93c53 100644 --- a/bluetooth-mitm/source/btm_mitm/btmmitm_module.hpp +++ b/bluetooth-mitm/source/btm_mitm/btmmitm_module.hpp @@ -19,7 +19,7 @@ namespace ams::mitm::btm { - void Launch(void); + Result Launch(void); void WaitFinished(void); } diff --git a/bluetooth-mitm/source/controllers/emulated_switch_controller.cpp b/bluetooth-mitm/source/controllers/emulated_switch_controller.cpp index a13e596..da68d72 100644 --- a/bluetooth-mitm/source/controllers/emulated_switch_controller.cpp +++ b/bluetooth-mitm/source/controllers/emulated_switch_controller.cpp @@ -54,46 +54,46 @@ namespace ams::controller { Result EmulatedSwitchController::HandleSubCmdReport(const bluetooth::HidReport *report) { const uint8_t *subcmd = &report->data[10]; - auto subcmd_id = static_cast(subcmd[0]); + auto subcmd_id = static_cast(subcmd[0]); switch (subcmd_id) { - case bluetooth::SubCmd_RequestDeviceInfo: + case SubCmd_RequestDeviceInfo: R_TRY(this->SubCmdRequestDeviceInfo(report)); break; - case bluetooth::SubCmd_SpiFlashRead: + case SubCmd_SpiFlashRead: R_TRY(this->SubCmdSpiFlashRead(report)); break; - case bluetooth::SubCmd_SpiFlashWrite: + case SubCmd_SpiFlashWrite: R_TRY(this->SubCmdSpiFlashWrite(report)); break; - case bluetooth::SubCmd_SpiSectorErase: + case SubCmd_SpiSectorErase: R_TRY(this->SubCmdSpiSectorErase(report)); break; - case bluetooth::SubCmd_SetInputReportMode: + case SubCmd_SetInputReportMode: R_TRY(this->SubCmdSetInputReportMode(report)); break; - case bluetooth::SubCmd_TriggersElapsedTime: + case SubCmd_TriggersElapsedTime: R_TRY(this->SubCmdTriggersElapsedTime(report)); break; - case bluetooth::SubCmd_SetShipPowerState: + case SubCmd_SetShipPowerState: R_TRY(this->SubCmdSetShipPowerState(report)); break; - case bluetooth::SubCmd_SetMcuConfig: + case SubCmd_SetMcuConfig: R_TRY(this->SubCmdSetMcuConfig(report)); break; - case bluetooth::SubCmd_SetMcuState: + case SubCmd_SetMcuState: R_TRY(this->SubCmdSetMcuState(report)); break; - case bluetooth::SubCmd_SetPlayerLeds: + case SubCmd_SetPlayerLeds: R_TRY(this->SubCmdSetPlayerLeds(report)); break; - case bluetooth::SubCmd_SetHomeLed: + case SubCmd_SetHomeLed: R_TRY(this->SubCmdSetHomeLed(report)); break; - case bluetooth::SubCmd_EnableImu: + case SubCmd_EnableImu: R_TRY(this->SubCmdEnableImu(report)); break; - case bluetooth::SubCmd_EnableVibration: + case SubCmd_EnableVibration: R_TRY(this->SubCmdEnableVibration(report)); break; default: @@ -121,7 +121,7 @@ namespace ams::controller { uint32_t read_addr = *(uint32_t *)(&report->data[11]); uint8_t read_size = report->data[15]; - const uint8_t prefix[] = {0x90, bluetooth::SubCmd_SpiFlashRead, report->data[11], report->data[12], report->data[13], report->data[14], report->data[15]}; + const uint8_t prefix[] = {0x90, SubCmd_SpiFlashRead, report->data[11], report->data[12], report->data[13], report->data[14], report->data[15]}; int response_size = read_size + sizeof(prefix); auto response = std::make_unique(response_size); @@ -137,37 +137,37 @@ namespace ams::controller { } Result EmulatedSwitchController::SubCmdSpiFlashWrite(const bluetooth::HidReport *report) { - const uint8_t response[] = {0x80, bluetooth::SubCmd_SpiFlashWrite, 0x01}; + const uint8_t response[] = {0x80, SubCmd_SpiFlashWrite, 0x01}; return this->FakeSubCmdResponse(response, sizeof(response)); } Result EmulatedSwitchController::SubCmdSpiSectorErase(const bluetooth::HidReport *report) { - const uint8_t response[] = {0x80, bluetooth::SubCmd_SpiSectorErase, 0x01}; + const uint8_t response[] = {0x80, SubCmd_SpiSectorErase, 0x01}; return this->FakeSubCmdResponse(response, sizeof(response)); } Result EmulatedSwitchController::SubCmdSetInputReportMode(const bluetooth::HidReport *report) { - const uint8_t response[] = {0x80, bluetooth::SubCmd_SetInputReportMode}; + const uint8_t response[] = {0x80, SubCmd_SetInputReportMode}; return this->FakeSubCmdResponse(response, sizeof(response)); } Result EmulatedSwitchController::SubCmdTriggersElapsedTime(const bluetooth::HidReport *report) { - const uint8_t response[] = {0x83, bluetooth::SubCmd_TriggersElapsedTime}; + const uint8_t response[] = {0x83, SubCmd_TriggersElapsedTime}; return this->FakeSubCmdResponse(response, sizeof(response)); } Result EmulatedSwitchController::SubCmdSetShipPowerState(const bluetooth::HidReport *report) { - const uint8_t response[] = {0x80, bluetooth::SubCmd_SetShipPowerState, 0x00}; + const uint8_t response[] = {0x80, SubCmd_SetShipPowerState, 0x00}; return this->FakeSubCmdResponse(response, sizeof(response)); } Result EmulatedSwitchController::SubCmdSetMcuConfig(const bluetooth::HidReport *report) { - const uint8_t response[] = {0xa0, bluetooth::SubCmd_SetMcuConfig, 0x01, 0x00, 0xff, 0x00, 0x03, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c}; + const uint8_t response[] = {0xa0, SubCmd_SetMcuConfig, 0x01, 0x00, 0xff, 0x00, 0x03, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c}; return this->FakeSubCmdResponse(response, sizeof(response)); } Result EmulatedSwitchController::SubCmdSetMcuState(const bluetooth::HidReport *report) { - const uint8_t response[] = {0x80, bluetooth::SubCmd_SetMcuState}; + const uint8_t response[] = {0x80, SubCmd_SetMcuState}; return this->FakeSubCmdResponse(response, sizeof(response)); } @@ -176,22 +176,22 @@ namespace ams::controller { uint8_t led_mask = subCmd[1]; R_TRY(this->SetPlayerLed(led_mask)); - const uint8_t response[] = {0x80, bluetooth::SubCmd_SetPlayerLeds}; + const uint8_t response[] = {0x80, SubCmd_SetPlayerLeds}; return this->FakeSubCmdResponse(response, sizeof(response)); } Result EmulatedSwitchController::SubCmdSetHomeLed(const bluetooth::HidReport *report) { - const uint8_t response[] = {0x80, bluetooth::SubCmd_SetHomeLed}; + const uint8_t response[] = {0x80, SubCmd_SetHomeLed}; return this->FakeSubCmdResponse(response, sizeof(response)); } Result EmulatedSwitchController::SubCmdEnableImu(const bluetooth::HidReport *report) { - const uint8_t response[] = {0x80, bluetooth::SubCmd_EnableImu}; + const uint8_t response[] = {0x80, SubCmd_EnableImu}; return this->FakeSubCmdResponse(response, sizeof(response)); } Result EmulatedSwitchController::SubCmdEnableVibration(const bluetooth::HidReport *report) { - const uint8_t response[] = {0x80, bluetooth::SubCmd_EnableVibration}; + const uint8_t response[] = {0x80, SubCmd_EnableVibration}; return this->FakeSubCmdResponse(response, sizeof(response)); } diff --git a/bluetooth-mitm/source/controllers/switch_controller.hpp b/bluetooth-mitm/source/controllers/switch_controller.hpp index 5dff600..8a1caa7 100644 --- a/bluetooth-mitm/source/controllers/switch_controller.hpp +++ b/bluetooth-mitm/source/controllers/switch_controller.hpp @@ -15,8 +15,8 @@ * along with this program. If not, see . */ #pragma once -#include "../bluetooth/bluetooth_types.hpp" -#include "../bluetooth/bluetooth_hid_report.hpp" +#include "../btdrv_mitm/bluetooth/bluetooth_types.hpp" +#include "../btdrv_mitm/bluetooth/bluetooth_hid_report.hpp" namespace ams::controller { @@ -68,6 +68,32 @@ namespace ams::controller { uint16_t gyro_3; } __attribute__ ((__packed__)); + enum SubCmdType : u8 { + SubCmd_GetControllerState = 0x00, + SubCmd_ManualPair = 0x01, + SubCmd_RequestDeviceInfo = 0x02, + SubCmd_SetInputReportMode = 0x03, + SubCmd_TriggersElapsedTime = 0x04, + SubCmd_SetHciState = 0x06, + SubCmd_ResetPairingInfo = 0x07, + SubCmd_SetShipPowerState = 0x08, + SubCmd_SpiFlashRead = 0x10, + SubCmd_SpiFlashWrite = 0x11, + SubCmd_SpiSectorErase = 0x12, + SubCmd_ResetMcu = 0x20, + SubCmd_SetMcuConfig = 0x21, + SubCmd_SetMcuState = 0x22, + SubCmd_SetPlayerLeds = 0x30, + SubCmd_GetPlayerLeds = 0x31, + SubCmd_SetHomeLed = 0x38, + SubCmd_EnableImu = 0x40, + SubCmd_SetImuSensitivity = 0x41, + SubCmd_WriteImuRegisters = 0x42, + SubCmd_ReadImuRegisters = 0x43, + SubCmd_EnableVibration = 0x48, + SubCmd_GetRegulatedVoltage = 0x50, + }; + struct SwitchOutputReport0x01; struct SwitchOutputReport0x03; struct SwitchOutputReport0x10;