Loading...
Searching...
No Matches
touch_dev.h
1/*
2 * Copyright (C) 2020 Inria
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
20#ifndef TOUCH_DEV_H
21#define TOUCH_DEV_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#include <stddef.h>
28#include <stdint.h>
29#include <stdbool.h>
30
34#define TOUCH_DEV_VALUE_INVALID ((touch_t){ UINT16_MAX, UINT16_MAX })
35
39typedef struct touch_dev touch_dev_t;
40
44typedef struct {
45 uint16_t x;
46 uint16_t y;
47} touch_t;
48
54typedef void (*touch_event_cb_t)(void *arg);
55
59typedef struct {
60
68 uint16_t (*height)(const touch_dev_t *dev);
69
77 uint16_t (*width)(const touch_dev_t *dev);
78
89 uint8_t (*max_numof)(const touch_dev_t *dev);
90
101 uint8_t (*touches)(const touch_dev_t *dev, touch_t *touches, size_t len);
102
110 void (*set_event_callback)(const touch_dev_t *dev, touch_event_cb_t cb, void *arg);
112
119
128
133
143
153
162
171
179static inline uint8_t touch_dev_max_numof(const touch_dev_t *dev)
180{
181 assert(dev);
182 return (dev->driver->max_numof) ? dev->driver->max_numof(dev) : 1;
183}
184
197uint8_t touch_dev_touches(const touch_dev_t *dev, touch_t *touches, size_t len);
198
207
208#ifdef __cplusplus
209}
210#endif
211
212#endif /* TOUCH_DEV_H */
#define assert(cond)
abort the program if assertion is false
Definition assert.h:137
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:179
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:54
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:59
uint8_t(* max_numof)(const touch_dev_t *dev)
Get the maximum number of touches the touch device supports.
Definition touch_dev.h:89
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:101
Touch dev registry entry.
Definition touch_dev.h:123
struct touch_dev_reg * next
pointer to the next touch device in the list
Definition touch_dev.h:124
touch_dev_t * dev
pointer to the device descriptor
Definition touch_dev.h:125
uint8_t screen_id
id of the screen this touch device is attached to
Definition touch_dev.h:126
Generic type for a touch device.
Definition touch_dev.h:116
const touch_dev_driver_t * driver
Pointer to driver of the touch device.
Definition touch_dev.h:117
Touch coordinates.
Definition touch_dev.h:44
uint16_t y
Y coordinate.
Definition touch_dev.h:46
uint16_t x
X coordinate.
Definition touch_dev.h:45