Touch support is split between BoardConfig.h, which says which controller
each device uses and which drivers a build compiles, and InputManager, which
holds the drivers. A build compiles only the drivers its selected
FREEINK_DEVICE_* profiles need, so a new device or controller has to be
registered in several places. This page lists every one.
All three edits are in libs/hardware/BoardConfig/include/BoardConfig.h.
FREEINK_TOUCH_DEVICE_SELECTED: addFREEINK_DEVICE_<NAME>. This list drives theFREEINK_CAP_TOUCHdefault and theFREEINK_TOUCH_ALL_DRIVERSfallback.FREEINK_TOUCH_<CONTROLLER>: addFREEINK_DEVICE_<NAME>to the flag of the controller the profile names, and add the device to the comment on that flag's#ifndefline.FREEINK_CHECK_TOUCH_DRIVER: addFREEINK_CHECK_TOUCH_DRIVER(FREEINK_DEVICE_<NAME>, <PROFILE>);next to the other lines afterDEFAULT_DEVICE. Add one line per profile the device can makeACTIVE, and add it for touchless devices too, so the check starts working if the profile gains a controller later.
Do everything in the device section above, plus the following.
BoardConfig.h:
enum class TouchController: append the new value at the end. Name it after the controller chip (Gt911,Tma525c), not after the board.- The flag: add an
#ifndef FREEINK_TOUCH_<CHIP>block next to the other driver flags, written in the same form:(FREEINK_CAP_TOUCH && (FREEINK_TOUCH_ALL_DRIVERS || FREEINK_DEVICE_<NAME>)). touchDriverCompiled(): add acasethat returns the new flag. The switch has nodefault, so-Wallwarns when a value is missing.
libs/hardware/InputManager/:
include/InputManager.h: declare the driver'sbegin<Chip>()/poll<Chip>(unsigned long now)and any helpers. Declarations are not gated; only definitions are.src/InputManager.cpp:- Wrap the driver's definitions and its file-local data in
#if FREEINK_TOUCH_<CHIP>…#endif // FREEINK_TOUCH_<CHIP>. If two drivers share helpers, gate the helpers on the OR of both flags. The FT5x06 register helpers, used by FT5x06 and CST816S, are an example. - Add a gated branch in
beginTouch()and a gatedcaseinserviceTouch(). A controller with no branch falls through to the "no driver" log and touch stays off, so a missing branch never shows up as a build error. - If the controller needs a sleep command or pin parking before deep
sleep, add it to
prepareForDeepSleep(). - Check the per-controller special cases for one the new chip also needs:
the controller-specific multi-contact queries, and CST816S's virtual buttons in
serviceTouch().
- Wrap the driver's definitions and its file-local data in
- Host test: add
test/host/run_<device>_touch.shand its stubs, usingrun_picco_touch.shorrun_eego.shas the template. Then run every InputManager suite plus the other suites that compileBoardConfig.h(AudioManager, HapticManager, BatteryMonitor, Imu). See testing.md.
Docs:
- Update the Capacitive touch paragraph and the device's row in the
Supported devices table in the root
README.md.
| Missed | Result |
|---|---|
1, FREEINK_TOUCH_DEVICE_SELECTED, device built alone |
Touch is off by default (FREEINK_CAP_TOUCH is 0). If you force it on with -D, every driver is kept. |
| 2, controller flag, device built alone | Build error from the step 3 static_assert, or from the DEFAULT_DEVICE assert if step 3 was also missed. |
2 and 3, device sharing a binary with listed devices and not DEFAULT_DEVICE |
No build error. The driver is compiled out, and touch logs [touch] no driver for touch controller N and stays off. This is the case the checklist guards against. |
6, touchDriverCompiled() case |
-Wswitch warning, and the static_asserts fail for that controller. |
| 8, dispatch branch | Builds, but touch logs the missing-driver line and stays off. |
The driver flags only know about the profiles compiled into the build. Code
that writes a different ACTIVE.touch.controller after boot, for example after
probing which digitizer is fitted, must build with
-DFREEINK_TOUCH_<CHIP>=1 for each controller it may switch to, or with
-DFREEINK_TOUCH_ALL_DRIVERS=1.