mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 10:53:17 +00:00
* **New Features** * Added a standalone LVGL module and enabled LVGL support in the simulator for richer local UI testing. * **Refactor** * HAL and LVGL split into distinct modules; startup and device attach/detach flows reorganized for clearer lifecycle management. * Public APIs tightened with clearer nullability/documentation. * **Bug Fixes** * More consistent LVGL start/stop and device attach/detach behavior for improved stability.
44 lines
1.5 KiB
C++
44 lines
1.5 KiB
C++
#include "tt_hal_touch.h"
|
|
|
|
#include <tactility/hal/Device.h>
|
|
#include "Tactility/hal/touch/TouchDevice.h"
|
|
#include "Tactility/hal/touch/TouchDriver.h"
|
|
|
|
struct DriverWrapper {
|
|
std::shared_ptr<tt::hal::touch::TouchDriver> driver;
|
|
DriverWrapper(std::shared_ptr<tt::hal::touch::TouchDriver> driver) : driver(driver) {}
|
|
};
|
|
|
|
static std::shared_ptr<tt::hal::touch::TouchDevice> findValidTouchDevice(tt::hal::Device::Id id) {
|
|
auto device = tt::hal::findDevice(id);
|
|
if (device == nullptr || device->getType() != tt::hal::Device::Type::Touch) {
|
|
return nullptr;
|
|
}
|
|
return std::reinterpret_pointer_cast<tt::hal::touch::TouchDevice>(device);
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
bool tt_hal_touch_driver_supported(DeviceId id) {
|
|
auto touch = findValidTouchDevice(id);
|
|
return touch != nullptr && touch->supportsTouchDriver();
|
|
}
|
|
|
|
TouchDriverHandle tt_hal_touch_driver_alloc(DeviceId id) {
|
|
auto touch = findValidTouchDevice(id);
|
|
assert(touch->supportsTouchDriver());
|
|
return new DriverWrapper(touch->getTouchDriver());
|
|
}
|
|
|
|
void tt_hal_touch_driver_free(TouchDriverHandle handle) {
|
|
DriverWrapper* wrapper = static_cast<DriverWrapper*>(handle);
|
|
delete wrapper;
|
|
}
|
|
|
|
bool tt_hal_touch_driver_get_touched_points(TouchDriverHandle handle, uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* pointCount, uint8_t maxPointCount) {
|
|
DriverWrapper* wrapper = static_cast<DriverWrapper*>(handle);
|
|
return wrapper->driver->getTouchedPoints(x, y, strength, pointCount, maxPointCount);
|
|
}
|
|
|
|
}
|