forked from zephyrproject-rtos/zephyr
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput_sdl_touch.c
47 lines (36 loc) · 1.15 KB
/
input_sdl_touch.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Copyright (c) 2020 Jabil Inc.
* Copyright (c) 2023 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_DRV_COMPAT zephyr_input_sdl_touch
#include <stdbool.h>
#include <zephyr/input/input.h>
#include <zephyr/logging/log.h>
#include "input_sdl_touch_bottom.h"
LOG_MODULE_REGISTER(sdl_input, CONFIG_INPUT_LOG_LEVEL);
static void sdl_input_callback(struct sdl_input_data *data)
{
if (data->just_released == true) {
input_report_key(data->dev, INPUT_BTN_TOUCH, 0, true, K_FOREVER);
data->just_released = false;
}
if (data->pressed) {
input_report_abs(data->dev, INPUT_ABS_X, data->x, false, K_FOREVER);
input_report_abs(data->dev, INPUT_ABS_Y, data->y, false, K_FOREVER);
input_report_key(data->dev, INPUT_BTN_TOUCH, 1, true, K_FOREVER);
}
}
static int sdl_init(const struct device *dev)
{
struct sdl_input_data *data = dev->data;
LOG_INF("Init '%s' device", dev->name);
data->dev = dev;
data->callback = sdl_input_callback;
sdl_input_init_bottom(data);
return 0;
}
static struct sdl_input_data sdl_data_0;
DEVICE_DT_INST_DEFINE(0, sdl_init, NULL, &sdl_data_0, NULL,
POST_KERNEL, CONFIG_INPUT_INIT_PRIORITY, NULL);