feat(T9): 九宫格输入法 + 多项 bug 修复

- T9 multi-tap 输入法:abc/ABC/123 三模式切换
- 修复 commitMultiTap 无限递归崩溃(重入保护)
- 修复 payload 残留导致非预期行为
- 修复 REGENERATE_FRAMESET 重复触发导致跳回主页面
- 修复大小写模式下出现数字(t9LetterMap 重做)
- 修复光标不跟随预览字符跳转(displayCursor +1)
- 修复按 0 无法输出空格(multiTapKey 无效标记 0→0xFF)
This commit is contained in:
2026-03-29 18:29:52 +08:00
parent eacbbc08dc
commit 614c0f77e8
3 changed files with 201 additions and 2 deletions
@@ -192,6 +192,16 @@ class CannedMessageModule : public SinglePortModule, public Observable<const UIF
int charSet = 0; // 0=ABC, 1=123
#endif
// === Multi-tap T9 input method (for TCA9535 numpad) ===
enum class InputMode : uint8_t { DIGIT, LOWER, UPPER };
InputMode inputMode = InputMode::LOWER; // 默认小写字母模式
uint8_t multiTapKey = 0xFF; // 上一次按的数字键 ('0'-'9'), 0xFF = no pending key
uint8_t multiTapIndex = 0; // 当前循环索引
uint32_t multiTapLastMs = 0; // 上一次按键时间戳
bool committingMultiTap = false; // 重入保护(commitMultiTap → runOnce → commitMultiTap
static constexpr uint32_t MULTI_TAP_TIMEOUT_MS = 800; // multi-tap 超时(ms
static const char *const t9LetterMap[][5]; // T9 字母模式映射表(UPPER/LOWER 模式用此表)
bool isUpEvent(const InputEvent *event);
bool isDownEvent(const InputEvent *event);
bool isSelectEvent(const InputEvent *event);
@@ -199,6 +209,8 @@ class CannedMessageModule : public SinglePortModule, public Observable<const UIF
int handleDestinationSelectionInput(const InputEvent *event, bool isUp, bool isDown, bool isSelect);
bool handleMessageSelectorInput(const InputEvent *event, bool isUp, bool isDown, bool isSelect);
bool handleFreeTextInput(const InputEvent *event);
bool commitMultiTap(); // Returns true if a character was actually committed
void showMultiTapPreview();
#if defined(USE_VIRTUAL_KEYBOARD)
Letter keyboard[2][4][10] = {{{{"Q", 20, 0, 0, 0, 0},