Detects a Tab5 Keyboard add-on that was plugged in after boot (so it wasn't started by Lvgl.cpp's attachDevices()). Once lateStart() succeeds, this stops polling for good — there's no support for re-detecting after the indev is torn down again.
| 79 | // Lvgl.cpp's attachDevices()). Once lateStart() succeeds, this stops polling for good — there's |
| 80 | // no support for re-detecting after the indev is torn down again. |
| 81 | static void keyboardDetectCallback(TimerHandle_t timer) { |
| 82 | if (kb_late_started.load(std::memory_order_acquire)) { |
| 83 | xTimerStop(timer, 0); |
| 84 | return; |
| 85 | } |
| 86 | |
| 87 | using namespace tt::hal; |
| 88 | auto keyboard = findFirstDevice<keyboard::KeyboardDevice>(tt::hal::Device::Type::Keyboard); |
| 89 | if (!keyboard) { |
| 90 | return; // Not registered yet, will retry on next tick |
| 91 | } |
| 92 | |
| 93 | if (keyboard->getLvglIndev() != nullptr) { |
| 94 | // Already started (boot-time attach) — nothing left to do. |
| 95 | kb_late_started.store(true, std::memory_order_release); |
| 96 | xTimerStop(timer, 0); |
| 97 | return; |
| 98 | } |
| 99 | |
| 100 | if (!keyboard->isAttached()) { |
| 101 | return; // Not plugged in yet, will retry on next tick |
| 102 | } |
| 103 | |
| 104 | auto tab5_keyboard = std::static_pointer_cast<Tab5Keyboard>(keyboard); |
| 105 | if (tab5_keyboard->lateStart()) { |
| 106 | LOG_I(TAG, "kb_detect: keyboard attached post-boot, LVGL input started"); |
| 107 | kb_late_started.store(true, std::memory_order_release); |
| 108 | xTimerStop(timer, 0); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | extern "C" { |
| 113 |
nothing calls this directly
no test coverage detected