diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 00c09fd..5e8eac0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,6 +30,9 @@ jobs: with: submodules: recursive + - name: Set firmware version + run: printf 'FIRMWARE_VERSION=%s\n' "${GITHUB_SHA::7}" >> "$GITHUB_ENV" + - name: Prepare build dependency cache id: apt-cache run: | @@ -79,7 +82,8 @@ jobs: run: | cmake -S . -B build/standard -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ - -DPICO_SDK_PATH="$PICO_SDK_PATH" + -DPICO_SDK_PATH="$PICO_SDK_PATH" \ + -DVERSION="$FIRMWARE_VERSION" cmake --build build/standard --target ds5-bridge mkdir -p artifacts cp build/standard/ds5-bridge.uf2 artifacts/ds5-bridge.uf2 @@ -90,7 +94,8 @@ jobs: -DCMAKE_BUILD_TYPE=Release \ -DPICO_SDK_PATH="$PICO_SDK_PATH" \ -DENABLE_SERIAL=ON \ - -DENABLE_VERBOSE=ON + -DENABLE_VERBOSE=ON \ + -DVERSION="$FIRMWARE_VERSION" cmake --build build/debug --target ds5-bridge cp build/debug/ds5-bridge.uf2 artifacts/ds5-bridge-debug.uf2 @@ -99,7 +104,8 @@ jobs: cmake -S . -B build/no-batt-led -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DPICO_SDK_PATH="$PICO_SDK_PATH" \ - -DENABLE_BATT_LED=OFF + -DENABLE_BATT_LED=OFF \ + -DVERSION="$FIRMWARE_VERSION" cmake --build build/no-batt-led --target ds5-bridge - name: Build Pico W firmware @@ -107,7 +113,8 @@ jobs: cmake -S . -B build/picow -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DPICO_SDK_PATH="$PICO_SDK_PATH" \ - -DPICO_W_BUILD=ON + -DPICO_W_BUILD=ON \ + -DVERSION="$FIRMWARE_VERSION" cmake --build build/picow --target ds5-bridge cp build/picow/ds5-bridge.uf2 artifacts/ds5-bridge-picow.uf2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 90652f8..8eb8133 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,6 +33,11 @@ jobs: ref: ${{ github.event.release.tag_name }} submodules: recursive + - name: Set firmware version + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + run: printf 'FIRMWARE_VERSION=%s\n' "$RELEASE_TAG" >> "$GITHUB_ENV" + - name: Prepare build dependency cache id: apt-cache run: | @@ -82,7 +87,8 @@ jobs: run: | cmake -S . -B build/standard -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ - -DPICO_SDK_PATH="$PICO_SDK_PATH" + -DPICO_SDK_PATH="$PICO_SDK_PATH" \ + -DVERSION="$FIRMWARE_VERSION" cmake --build build/standard --target ds5-bridge mkdir -p artifacts cp build/standard/ds5-bridge.uf2 "artifacts/ds5-bridge-${{ github.event.release.tag_name }}.uf2" @@ -93,7 +99,8 @@ jobs: -DCMAKE_BUILD_TYPE=Release \ -DPICO_SDK_PATH="$PICO_SDK_PATH" \ -DENABLE_SERIAL=ON \ - -DENABLE_VERBOSE=ON + -DENABLE_VERBOSE=ON \ + -DVERSION="$FIRMWARE_VERSION" cmake --build build/debug --target ds5-bridge cp build/debug/ds5-bridge.uf2 "artifacts/ds5-bridge-debug-${{ github.event.release.tag_name }}.uf2" diff --git a/CMakeLists.txt b/CMakeLists.txt index e660178..fcec7fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,9 +141,10 @@ if(WAKE_DEBUG) WAKE_DEBUG ) endif() +set(VERSION "dev" CACHE STRING "Program version string") pico_set_program_name(ds5-bridge "ds5-bridge") -pico_set_program_version(ds5-bridge "0.5.3") +pico_set_program_version(ds5-bridge "${VERSION}") # Modify the below lines to enable/disable output over UART/USB pico_enable_stdio_uart(ds5-bridge 1) diff --git a/src/cmd.cpp b/src/cmd.cpp index caea2da..8dfc217 100644 --- a/src/cmd.cpp +++ b/src/cmd.cpp @@ -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(reqlen)); + memcpy(buffer, PICO_PROGRAM_VERSION_STRING, len); + return len; + } return 0; } diff --git a/src/config.h b/src/config.h index 69c8a6b..2add120 100644 --- a/src/config.h +++ b/src/config.h @@ -8,6 +8,7 @@ #include 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 diff --git a/src/usb_descriptors.cpp b/src/usb_descriptors.cpp index 2d32ff4..17964bd 100644 --- a/src/usb_descriptors.cpp +++ b/src/usb_descriptors.cpp @@ -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