From 41c89ebcfd8a43ce49453e780248c68bb35d35df Mon Sep 17 00:00:00 2001 From: MarcelineVPQ Date: Sun, 17 May 2026 07:55:20 -0600 Subject: [PATCH] =?UTF-8?q?rebase:=20Phase=20C=20=E2=80=94=20main.cpp=20wi?= =?UTF-8?q?res=20OLED=20+=20PS+Mute=20reboot=20combo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three additions on top of upstream's v0.6.0-hotfix main.cpp: - #include "oled.h" + oled_init() after audio_init/state_init, oled_loop() in the main while(1). - PS + Mute hold-2-seconds combo at the top of interrupt_loop() for headless soft-reboot via watchdog_reboot(0,0,0). Bit pattern (interrupt_in_data[9] & 0x05) is rare in normal gameplay so the long hold prevents accidental triggers. Upstream's state_init() call sits right between audio_init() and our new oled_init() — preserved as-is. The state_mgr → 0x31 output report flow in tud_hid_set_report_cb is upstream's rumble path; not touched. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/main.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index e384e6c..f83e52e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,7 @@ #if ENABLE_BATT_LED #include "battery_led.h" #endif +#include "oled.h" // Pico SDK speciifically for waiting on conditions #include "pico/critical_section.h" @@ -44,6 +45,23 @@ critical_section_t report_cs; volatile bool report_dirty = false; void interrupt_loop() { + // OLED Edition: hold PS + Mute for 2 seconds to soft-reboot the dongle. + // Works whether or not the OLED add-on is present. PS+Mute is uncommon + // during gameplay and the long hold avoids accidental triggers. + { + static uint32_t combo_first_us = 0; + constexpr uint8_t kComboBits = 0x05; // byte 9: PS (bit 0) + Mute (bit 2) + constexpr uint32_t kComboHoldUs = 2000000; // 2 seconds + const bool held = (interrupt_in_data[9] & kComboBits) == kComboBits; + if (held) { + const uint32_t now = time_us_32(); + if (combo_first_us == 0) combo_first_us = now; + else if ((now - combo_first_us) > kComboHoldUs) watchdog_reboot(0, 0, 0); + } else { + combo_first_us = 0; + } + } + if (!tud_hid_ready()) return; // TODO: Refactor for better code reuse @@ -252,6 +270,7 @@ int main() { audio_init(); state_init(); + oled_init(); #if !ENABLE_SERIAL watchdog_enable(1000, true); @@ -265,6 +284,7 @@ int main() { tud_task(); audio_loop(); interrupt_loop(); + oled_loop(); #if ENABLE_BATT_LED battery_led_tick(); #endif