Fix backtick back button to work reliably, improve Terminal Shell responsiveness, enhance HID Injector feedback

This commit is contained in:
Claude
2026-09-26 00:12:22 +00:00
parent b76f016bcd
commit c6dfc19578
3 changed files with 12 additions and 8 deletions

View File

@@ -159,20 +159,20 @@ void Shell::loop() {
if (M5Cardputer.Keyboard.isChange() && M5Cardputer.Keyboard.isPressed()) { if (M5Cardputer.Keyboard.isChange() && M5Cardputer.Keyboard.isPressed()) {
auto st = M5Cardputer.Keyboard.keysState(); auto st = M5Cardputer.Keyboard.keysState();
for (char c : st.word) { for (char c : st.word) {
if (c == '`') { if (active >= 0) back(); continue; } if (c == '`' || c == 27) { if (active >= 0) { back(); continue; } }
if (active < 0) { if (active < 0) {
if (c == ';') { sel = (sel - 1 + nmods) % nmods; drawMenu(); } if (c == ';') { sel = (sel - 1 + nmods) % nmods; drawMenu(); }
else if (c == '.') { sel = (sel + 1) % nmods; drawMenu(); } else if (c == '.') { sel = (sel + 1) % nmods; drawMenu(); }
else if (c == '\r' || c == ' ') enter(sel); else if (c == '\r' || c == ' ') enter(sel);
} else { } else {
mods[active]->onKey(c); bool consumed = mods[active]->onKey(c);
if (!consumed && c == '`') back();
} }
} }
if (st.enter && active < 0) enter(sel); if (st.enter && active < 0) enter(sel);
} }
if (active < 0) { if (active < 0) {
// keep the selection glow breathing — repaints only the bar strip (flicker-free)
if (millis() - lastTick > 90) { lastTick = millis(); drawMenu(false); } if (millis() - lastTick > 90) { lastTick = millis(); drawMenu(false); }
return; return;
} }

View File

@@ -21,12 +21,13 @@ public:
void onEnter() override { void onEnter() override {
active = false; active = false;
sent = 0; sent = 0;
say("HID ready, plug USB host"); say("HID ready");
#ifdef HAVE_TINYSB #ifdef HAVE_TINYSB
if (tud_mounted()) { if (tud_mounted()) {
active = true; active = true;
sent = 0; sent = 0;
say("Host detected - injecting"); say("Host detected!");
say("Injecting...");
} }
#endif #endif
} }

View File

@@ -43,10 +43,13 @@ public:
void tick() override { void tick() override {
if (!connected) return; if (!connected) return;
while (ser.available()) { uint32_t start = millis();
while (ser.available() && millis() - start < 10) {
char c = ser.read(); char c = ser.read();
if (rxPos < sizeof(rxBuffer) - 1) rxBuffer[rxPos++] = c; if (rxPos < sizeof(rxBuffer) - 1) {
if (rxPos >= sizeof(rxBuffer) - 1) rxPos = sizeof(rxBuffer) - 1; rxBuffer[rxPos++] = c;
if (c == '\n') rxPos = 0;
}
} }
} }