From e017b7415f6096d2a478646779ad4505a31874e1 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Mon, 9 Feb 2026 20:14:55 +0100 Subject: [PATCH] Fix for T-Deck apps not showing up and added new kernel functionality --- Tactility/Source/Tactility.cpp | 33 ++++++++++--------- TactilityKernel/Include/tactility/device.h | 8 +++++ .../Include/tactility/drivers/root.h | 10 ++++++ TactilityKernel/Include/tactility/error.h | 1 + TactilityKernel/Source/device.cpp | 5 +++ TactilityKernel/Source/drivers/root.cpp | 6 ++++ TactilityKernel/Source/kernel_symbols.c | 4 +++ 7 files changed, 51 insertions(+), 16 deletions(-) diff --git a/Tactility/Source/Tactility.cpp b/Tactility/Source/Tactility.cpp index 5d83a1a8..942a9dcb 100644 --- a/Tactility/Source/Tactility.cpp +++ b/Tactility/Source/Tactility.cpp @@ -32,6 +32,7 @@ #include #ifdef ESP_PLATFORM +#include "tactility/drivers/root.h" #include #endif @@ -61,8 +62,6 @@ namespace service { namespace statusbar { extern const ServiceManifest manifest; } #ifdef ESP_PLATFORM namespace displayidle { extern const ServiceManifest manifest; } -#endif -#if defined(ESP_PLATFORM) && defined(CONFIG_TT_DEVICE_LILYGO_TDECK) namespace keyboardidle { extern const ServiceManifest manifest; } #endif #if TT_FEATURE_SCREENSHOT_ENABLED @@ -112,11 +111,8 @@ namespace app { #ifdef ESP_PLATFORM namespace crashdiagnostics { extern const AppManifest manifest; } namespace webserversettings { extern const AppManifest manifest; } -#endif - -#if defined(ESP_PLATFORM) && defined(CONFIG_TT_DEVICE_LILYGO_TDECK) - namespace keyboardsettings { extern const AppManifest manifest; } - namespace trackballsettings { extern const AppManifest manifest; } + namespace keyboardsettings { extern const AppManifest manifest; } // T-Deck only for now + namespace trackballsettings { extern const AppManifest manifest; } // T-Deck only for now #endif #if TT_FEATURE_SCREENSHOT_ENABLED @@ -162,11 +158,13 @@ static void registerInternalApps() { addAppManifest(app::webserversettings::manifest); addAppManifest(app::crashdiagnostics::manifest); addAppManifest(app::development::manifest); -#endif - -#if defined(ESP_PLATFORM) && defined(CONFIG_TT_DEVICE_LILYGO_TDECK) - addAppManifest(app::keyboardsettings::manifest); - addAppManifest(app::trackballsettings::manifest); + // T-Deck only: + auto* root_device = device_find_by_name("/"); + check(root_device); + if (root_is_model(root_device, "LilyGO T-Deck")) { + addAppManifest(app::keyboardsettings::manifest); + addAppManifest(app::trackballsettings::manifest); + } #endif #if defined(CONFIG_TINYUSB_MSC_ENABLED) && CONFIG_TINYUSB_MSC_ENABLED @@ -251,13 +249,16 @@ static void registerAndStartSecondaryServices() { addService(service::loader::manifest); addService(service::gui::manifest); addService(service::statusbar::manifest); + addService(service::memorychecker::manifest); #ifdef ESP_PLATFORM addService(service::displayidle::manifest); + // T-Deck only: + auto* root_device = device_find_by_name("/"); + check(root_device); + if (root_is_model(root_device, "LilyGO T-Deck")) { + addService(service::keyboardidle::manifest); + } #endif -#if defined(ESP_PLATFORM) && defined(CONFIG_TT_DEVICE_LILYGO_TDECK) - addService(service::keyboardidle::manifest); -#endif - addService(service::memorychecker::manifest); #if TT_FEATURE_SCREENSHOT_ENABLED addService(service::screenshot::manifest); #endif diff --git a/TactilityKernel/Include/tactility/device.h b/TactilityKernel/Include/tactility/device.h index 1be4b498..af4595e5 100644 --- a/TactilityKernel/Include/tactility/device.h +++ b/TactilityKernel/Include/tactility/device.h @@ -178,6 +178,14 @@ struct Device* device_get_parent(struct Device* device); */ bool device_is_ready(const struct Device* device); +/** + * Indicates whether the device is compatible with the given compatible string. + * @param[in] device non-null device pointer + * @param[in] compatible compatible string + * @return true if the device is compatible + */ +bool device_is_compatible(const struct Device* device, const char* compatible); + /** * Set the driver data for a device. * diff --git a/TactilityKernel/Include/tactility/drivers/root.h b/TactilityKernel/Include/tactility/drivers/root.h index e2797b93..f6fe8aa1 100644 --- a/TactilityKernel/Include/tactility/drivers/root.h +++ b/TactilityKernel/Include/tactility/drivers/root.h @@ -2,6 +2,8 @@ #pragma once +#include + #ifdef __cplusplus extern "C" { #endif @@ -10,6 +12,14 @@ struct RootConfig { const char* model; }; +/** + * Indicates whether the device's model matches the specified model. + * @param[in] device the device to check (non-null) + * @param[in] model the model to check against + * @return true if the device's model matches the specified model' + */ +bool root_is_model(const struct Device* device, const char* model); + #ifdef __cplusplus } #endif diff --git a/TactilityKernel/Include/tactility/error.h b/TactilityKernel/Include/tactility/error.h index f01ee259..094a4c92 100644 --- a/TactilityKernel/Include/tactility/error.h +++ b/TactilityKernel/Include/tactility/error.h @@ -23,6 +23,7 @@ typedef int error_t; #define ERROR_OUT_OF_MEMORY 9 #define ERROR_NOT_SUPPORTED 10 #define ERROR_NOT_ALLOWED 11 +#define ERROR_BUFFER_OVERFLOW 12 /** Convert an error_t to a human-readable text. Useful for logging. */ const char* error_to_string(error_t error); diff --git a/TactilityKernel/Source/device.cpp b/TactilityKernel/Source/device.cpp index 3e19b5b5..b752faae 100644 --- a/TactilityKernel/Source/device.cpp +++ b/TactilityKernel/Source/device.cpp @@ -277,6 +277,11 @@ bool device_is_ready(const struct Device* device) { return device->internal->state.started; } +bool device_is_compatible(const struct Device* device, const char* compatible) { + if (device->internal->driver == nullptr) return false; + return driver_is_compatible(device->internal->driver, compatible); +} + void device_set_driver_data(struct Device* device, void* driver_data) { device->internal->driver_data = driver_data; } diff --git a/TactilityKernel/Source/drivers/root.cpp b/TactilityKernel/Source/drivers/root.cpp index 0288e4c1..f1c04ccd 100644 --- a/TactilityKernel/Source/drivers/root.cpp +++ b/TactilityKernel/Source/drivers/root.cpp @@ -1,10 +1,16 @@ // SPDX-License-Identifier: Apache-2.0 +#include #include #include extern "C" { +bool root_is_model(const struct Device* device, const char* buffer) { + auto* config = static_cast(device->config); + return strcmp(config->model, buffer) == 0; +} + Driver root_driver = { .name = "root", .compatible = (const char*[]) { "root", nullptr }, diff --git a/TactilityKernel/Source/kernel_symbols.c b/TactilityKernel/Source/kernel_symbols.c index e9686ea2..205383c5 100644 --- a/TactilityKernel/Source/kernel_symbols.c +++ b/TactilityKernel/Source/kernel_symbols.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,7 @@ const struct ModuleSymbol KERNEL_SYMBOLS[] = { DEFINE_MODULE_SYMBOL(device_get_driver_data), DEFINE_MODULE_SYMBOL(device_is_added), DEFINE_MODULE_SYMBOL(device_is_ready), + DEFINE_MODULE_SYMBOL(device_is_compatible), DEFINE_MODULE_SYMBOL(device_lock), DEFINE_MODULE_SYMBOL(device_try_lock), DEFINE_MODULE_SYMBOL(device_unlock), @@ -79,6 +81,8 @@ const struct ModuleSymbol KERNEL_SYMBOLS[] = { DEFINE_MODULE_SYMBOL(i2s_controller_get_config), DEFINE_MODULE_SYMBOL(i2s_controller_reset), DEFINE_MODULE_SYMBOL(I2S_CONTROLLER_TYPE), + // drivers/root + DEFINE_MODULE_SYMBOL(root_is_model), // drivers/spi_controller DEFINE_MODULE_SYMBOL(spi_controller_lock), DEFINE_MODULE_SYMBOL(spi_controller_try_lock),