Loading...
Searching...
No Matches
touch_dev.h
1/*
2 * SPDX-FileCopyrightText: 2020 Inria
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#include <stddef.h>
24#include <stdint.h>
25#include <stdbool.h>
26
30#define TOUCH_DEV_VALUE_INVALID ((touch_t){ UINT16_MAX, UINT16_MAX })
31
35typedef struct touch_dev touch_dev_t;
36
40typedef struct {
41 uint16_t x;
42 uint16_t y;
43} touch_t;
44
50typedef void (*touch_event_cb_t)(void *arg);
51
55typedef struct {
56
64 uint16_t (*height)(const touch_dev_t *dev);
65
73 uint16_t (*width)(const touch_dev_t *dev);
74
85 uint8_t (*max_numof)(const touch_dev_t *dev);
86
97 uint8_t (*touches)(const touch_dev_t *dev, touch_t *touches, size_t len);
98
106 void (*set_event_callback)(const touch_dev_t *dev, touch_event_cb_t cb, void *arg);
108
115
124
129
139
149
158
167
175static inline uint8_t touch_dev_max_numof(const touch_dev_t *dev)
176{
177 assert(dev);
178 return (dev->driver->max_numof) ? dev->driver->max_numof(dev) : 1;
179}
180
193uint8_t touch_dev_touches(const touch_dev_t *dev, touch_t *touches, size_t len);
194
203
204#ifdef __cplusplus
205}
206#endif
207
#define assert(cond)
abort the program if assertion is false
Definition assert.h:143
int touch_dev_reg_add(touch_dev_reg_t *dev)
Add pointer to a touch device item to the list of touch items.
static uint8_t touch_dev_max_numof(const touch_dev_t *dev)
Get the maximum number of touches the touch device supports.
Definition touch_dev.h:175
struct touch_dev touch_dev_t
Forward declaration for touch device struct.
Definition touch_dev.h:35
uint8_t touch_dev_touches(const touch_dev_t *dev, touch_t *touches, size_t len)
Get the current touches on the touch device.
void(* touch_event_cb_t)(void *arg)
Signature of touch event callback triggered from interrupt.
Definition touch_dev.h:50
uint16_t touch_dev_height(const touch_dev_t *dev)
Get the height of the touch device.
struct touch_dev_reg touch_dev_reg_t
Touch dev registry entry.
uint16_t touch_dev_width(const touch_dev_t *dev)
Get the width of the touch device.
void touch_dev_set_touch_event_callback(const touch_dev_t *dev, touch_event_cb_t cb, void *arg)
Set and configure the touch event callback.
touch_dev_reg_t * touch_dev_reg_find_screen(uint8_t screen_id)
Find the touch device that is attached to a given screen.
Generic type for a touch driver.
Definition touch_dev.h:55
uint16_t(* width)(const touch_dev_t *dev)
Get the width of the touch device.
Definition touch_dev.h:73
void(* set_event_callback)(const touch_dev_t *dev, touch_event_cb_t cb, void *arg)
Set and configure the touch event callback.
Definition touch_dev.h:106
uint8_t(* max_numof)(const touch_dev_t *dev)
Get the maximum number of touches the touch device supports.
Definition touch_dev.h:85
uint16_t(* height)(const touch_dev_t *dev)
Get the height of the touch device.
Definition touch_dev.h:64
uint8_t(* touches)(const touch_dev_t *dev, touch_t *touches, size_t len)
Get the current touches on the touch device.
Definition touch_dev.h:97
Touch dev registry entry.
Definition touch_dev.h:119
struct touch_dev_reg * next
pointer to the next touch device in the list
Definition touch_dev.h:120
touch_dev_t * dev
pointer to the device descriptor
Definition touch_dev.h:121
uint8_t screen_id
id of the screen this touch device is attached to
Definition touch_dev.h:122
Generic type for a touch device.
Definition touch_dev.h:112
const touch_dev_driver_t * driver
Pointer to driver of the touch device.
Definition touch_dev.h:113
Touch coordinates.
Definition touch_dev.h:40
uint16_t y
Y coordinate.
Definition touch_dev.h:42
uint16_t x
X coordinate.
Definition touch_dev.h:41