feat: add 0xf8 feature report to get firmware version and add config version
This commit is contained in:
+8
-1
@@ -14,7 +14,8 @@
|
||||
|
||||
bool is_pico_cmd(uint8_t report_id) {
|
||||
if (report_id == 0xf6 ||
|
||||
report_id == 0xf7
|
||||
report_id == 0xf7 ||
|
||||
report_id == 0xf8
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
@@ -31,6 +32,12 @@ uint16_t pico_cmd_get(uint8_t report_id, uint8_t *buffer, uint16_t reqlen) {
|
||||
memcpy(buffer,&get_config(),len);
|
||||
return len;
|
||||
}
|
||||
if (report_id == 0xf8) {
|
||||
printf("[HID] Receive 0xf8 getting firmware version\n");
|
||||
const auto len = std::min(strlen(PICO_PROGRAM_VERSION_STRING), static_cast<size_t>(reqlen));
|
||||
memcpy(buffer, PICO_PROGRAM_VERSION_STRING, len);
|
||||
return len;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <cstdint>
|
||||
|
||||
struct __attribute__((packed)) Config_body {
|
||||
uint8_t config_version = 1; // Config Version
|
||||
float haptics_gain; // [1.0,2.0]
|
||||
float speaker_volume; // [-100,0]
|
||||
uint8_t inactive_time; // [10,60] min
|
||||
|
||||
+16
-6
@@ -362,8 +362,8 @@ uint8_t descriptor_configuration[] = {
|
||||
0x00, // bCountryCode: Not localized
|
||||
0x01, // bNumDescriptors: 1 report descriptor
|
||||
0x22, // bDescriptorType: Report
|
||||
0x31, 0x01, // wDescriptorLength: 305 (0x0131) DS
|
||||
// 0xA5, 0x01, // wDescriptorLength: 421 (0x01A5) DSE
|
||||
0x39, 0x01, // wDescriptorLength: 313 (0x0139) DS
|
||||
// 0xAD, 0x01, // wDescriptorLength: 429 (0x01AD) DSE
|
||||
|
||||
// Endpoint Descriptor (HID IN: EP4)
|
||||
0x07, // bLength
|
||||
@@ -408,9 +408,9 @@ uint8_t const *tud_descriptor_configuration_cb(uint8_t index) {
|
||||
descriptor_configuration[offset - 1] = bInterval;
|
||||
descriptor_configuration[offset - 8] = bInterval;
|
||||
if (ds_mode()) {
|
||||
descriptor_configuration[offset - 16] = 0x31;
|
||||
descriptor_configuration[offset - 16] = 0x39;
|
||||
}else {
|
||||
descriptor_configuration[offset - 16] = 0xA5;
|
||||
descriptor_configuration[offset - 16] = 0xAD;
|
||||
}
|
||||
return descriptor_configuration;
|
||||
}
|
||||
@@ -569,9 +569,14 @@ uint8_t const desc_hid_report_ds[] = {
|
||||
0x09, 0x38,
|
||||
0x95, 0x3F,
|
||||
0xB1, 0x02,
|
||||
0x85, 0xF8,
|
||||
0x09, 0x39,
|
||||
0x95, 0x3F,
|
||||
0xB1, 0x02,
|
||||
0xC0, // End Collection
|
||||
// 305 bytes
|
||||
// 313 bytes
|
||||
};
|
||||
static_assert(sizeof(desc_hid_report_ds) == 0x0139);
|
||||
|
||||
uint8_t const desc_hid_report_dse[] = {
|
||||
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
|
||||
@@ -781,9 +786,14 @@ uint8_t const desc_hid_report_dse[] = {
|
||||
0x09, 0x38,
|
||||
0x95, 0x3F,
|
||||
0xB1, 0x02,
|
||||
0x85, 0xF8,
|
||||
0x09, 0x39,
|
||||
0x95, 0x3F,
|
||||
0xB1, 0x02,
|
||||
0xC0, // End Collection
|
||||
// 421 bytes
|
||||
// 429 bytes
|
||||
};
|
||||
static_assert(sizeof(desc_hid_report_dse) == 0x01AD);
|
||||
|
||||
// Invoked when received GET HID REPORT DESCRIPTOR
|
||||
// Application return pointer to descriptor
|
||||
|
||||
Reference in New Issue
Block a user