Connect to the Input Events library

Callback functions and capabilities of your touch controller need to be configured and specified, respectively, before connecting to the Input Events library.

Configure callback functions

Assign your driver's callback functions appropriately by using the structure mtouch_driver_funcs_t.

For example:

mtouch_driver_funcs_t funcs = {
	.get_contact_id = get_contact_id,
	.is_contact_down = is_contact_down,
	.get_coords = get_coords,
	.get_down_count = get_down_count,
	.get_touch_width = NULL,
	.get_touch_height = NULL,
	.get_touch_orientation = NULL,
	.get_touch_pressure = NULL,
	.get_seq_id = NULL,
	.set_event_rate = NULL,
	.get_contact_type = NULL,
	.get_select = NULL
};
      

Specify driver parameters

Specify the capabilities that are supported by your driver. Use the structure mtouch_driver_params_t.

For example:

mtouch_driver_params_t params = {
	.capabilities = MTOUCH_CAPABILITIES_CONTACT_ID |
	                MTOUCH_CAPABILITIES_COORDS |
	                MTOUCH_CAPABILITIES_CONTACT_COUNT,
	.flags = 0,
	.max_touchpoints = 2,
	.width = 1312,
	.height = 800
};

Connect to the Input Events library

After having assigned your callback functions and having specified your driver parameters, you use the function mtouch_driver_attach() to connect to the Input Events library.

For example:

struct mtouch_device* inputevents_hdl;
inputevents_hdl = mtouch_driver_attach(&params, &funcs);