auto switch ds mode
This commit is contained in:
+16
-1
@@ -36,6 +36,7 @@ static hci_con_handle_t acl_handle = HCI_CON_HANDLE_INVALID;
|
||||
static uint16_t hid_control_cid;
|
||||
static uint16_t hid_interrupt_cid;
|
||||
static bt_data_callback_t bt_data_callback = nullptr;
|
||||
static bool check_dse = false;
|
||||
unordered_map<uint8_t, vector<uint8_t> > feature_data;
|
||||
queue_t send_fifo;
|
||||
|
||||
@@ -337,6 +338,15 @@ static void l2cap_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t
|
||||
bt_disconnect();
|
||||
}
|
||||
} else if (channel == hid_control_cid) {
|
||||
if (check_dse) {
|
||||
check_dse = false;
|
||||
if (packet[0] == 0x02) {
|
||||
is_dse = false;
|
||||
}else if (size > 1){
|
||||
is_dse = true;
|
||||
}
|
||||
tud_connect();
|
||||
}
|
||||
if (packet[0] == 0xA3) {
|
||||
uint8_t report_id = packet[1];
|
||||
feature_data[report_id].assign(packet + 1, packet + size);
|
||||
@@ -396,7 +406,7 @@ static void l2cap_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t
|
||||
memcpy(report32 + 2, packet_0x10, sizeof(packet_0x10));
|
||||
bt_write(report32, sizeof(report32));
|
||||
|
||||
tud_connect();
|
||||
// tud_connect();
|
||||
} else {
|
||||
printf("[L2CAP] Unknown Channel psm: 0x%02X", psm);
|
||||
}
|
||||
@@ -518,4 +528,9 @@ void init_feature() {
|
||||
get_feature_data(0x20, 64);
|
||||
get_feature_data(0x22, 64);
|
||||
get_feature_data(0x05, 41);
|
||||
// DSE
|
||||
// check DSE by request 0x70 feature report. DSE return DEFAULT
|
||||
// If len == 1, it's DS5
|
||||
check_dse = true;
|
||||
get_feature_data(0x70, 64);
|
||||
}
|
||||
|
||||
+2
-2
@@ -74,8 +74,8 @@ void config_valid() {
|
||||
body->haptics_buffer_length = 64;
|
||||
printf("[Config] haptics_buffer_length is invalid\n");
|
||||
}
|
||||
if (body->controller_mode > 1) {
|
||||
body->controller_mode = 0;
|
||||
if (body->controller_mode > 2) {
|
||||
body->controller_mode = 2;
|
||||
printf("[Config] controller_mode is invalid\n");
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -15,7 +15,7 @@ struct __attribute__((packed)) Config_body {
|
||||
uint8_t disable_pico_led; // bool
|
||||
uint8_t polling_rate_mode; // 0: 250Hz, 1: 500Hz, 2: real-time
|
||||
uint8_t haptics_buffer_length; // [16,128]
|
||||
uint8_t controller_mode; // 0: DS5, 1: DSE 自动切换识别太麻烦了,懒的做了,期待pr
|
||||
uint8_t controller_mode; // 0: DS5, 1: DSE, 2: Auto
|
||||
};
|
||||
|
||||
struct __attribute__((packed)) Config {
|
||||
@@ -33,5 +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;
|
||||
|
||||
#endif //DS5_BRIDGE_CONFIG_H
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
#include "config.h"
|
||||
|
||||
bool ds_mode() {
|
||||
if (get_config().controller_mode == 2) {
|
||||
return !is_dse;
|
||||
}
|
||||
return get_config().controller_mode == 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user