Writing a Touch Driver

Updated: May 06, 2022

In order for Screen to be able to detect events from your touch controller, you need to provide a driver for your touch controller.

Your driver is required to provide the following:

Provide the required callback functions
Your driver must provide implementation for the callback functions: get_coords(), get_contact_id(), and is_contact_down(). Other callback functions that need to be implemented depend on the capabilities that you have specfied being supported by your driver.
Connect to the Input Events library
You need to specify the appropriate callback functions and the mtouch driver parameters for your touch controller. Once the callback functions and parameters have been set, you can connect to the Input Events library by calling the function mtouch_driver_attach().
Communicate with the hardware
You need to communicate directly with the hardware via the hardware interface (e.g., I2C, SPI, USB, etc.).
Implement initialization and cleanup callback functions
Your driver must provide implementation for the callback functions: mtouch_driver_init() and mtouch_driver_fini(). These functions are your driver's insertion and exit points, respectively, for Screen.
Disconnect from the Input Events library
You need to perform the appropriate cleanup of resources and disconnect from the Input Events library by calling the function mtouch_driver_detach().