diff --git a/src/bt.cpp b/src/bt.cpp index fc76857..0cddee5 100644 --- a/src/bt.cpp +++ b/src/bt.cpp @@ -341,15 +341,21 @@ static void l2cap_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t } } else if (channel == hid_control_cid) { if (check_dse) { - check_dse = false; - if (packet[0] == 0x02) { - is_dse = false; - }else if (size > 1){ + if (packet[0] == 0xA3 && packet[1] == 0x70) { + printf("Connected DSE Controller\n"); + check_dse = false; is_dse = true; - } #if !ENABLE_SERIAL - tud_connect(); + tud_connect(); #endif + }else if (packet[0] == 0x02) { + printf("Connected DS5 Controller\n"); + check_dse = false; + is_dse = false; +#if !ENABLE_SERIAL + tud_connect(); +#endif + } } if (packet[0] == 0xA3) { uint8_t report_id = packet[1]; diff --git a/src/config.cpp b/src/config.cpp index 9e71b8c..d81d9ca 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -16,6 +16,7 @@ constexpr uint32_t CONFIG_MAGIC = 0x66ccff00; constexpr uint16_t CONFIG_VERSION = 1; constexpr uint32_t CONFIG_FLASH_OFFSET = PICO_FLASH_SIZE_BYTES - FLASH_SECTOR_SIZE; static Config config{}; +bool is_dse = false; // 编译期保护 // 判断Config结构体是否能放进flash 256bytes diff --git a/src/config.h b/src/config.h index 7c21b55..5d73272 100644 --- a/src/config.h +++ b/src/config.h @@ -33,6 +33,6 @@ const Config_body& get_config(); void set_config(const uint8_t *new_config, const uint16_t len); void config_valid(); void set_config(const Config_body &new_config); -static bool is_dse = false; +extern bool is_dse; #endif //DS5_BRIDGE_CONFIG_H