Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
input.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_INCLUDE_INPUT_INPUT_H_
14#define ZEPHYR_INCLUDE_INPUT_INPUT_H_
15
29
30#include <stdint.h>
31#include <zephyr/device.h>
33#include <zephyr/kernel.h>
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
63
82int input_report(const struct device *dev,
83 uint8_t type, uint16_t code, int32_t value, bool sync,
84 k_timeout_t timeout);
85
92static inline int input_report_key(const struct device *dev,
93 uint16_t code, int32_t value, bool sync,
94 k_timeout_t timeout)
95{
96 return input_report(dev, INPUT_EV_KEY, code, !!value, sync, timeout);
97}
98
104static inline int input_report_rel(const struct device *dev,
105 uint16_t code, int32_t value, bool sync,
106 k_timeout_t timeout)
107{
108 return input_report(dev, INPUT_EV_REL, code, value, sync, timeout);
109}
110
116static inline int input_report_abs(const struct device *dev,
117 uint16_t code, int32_t value, bool sync,
118 k_timeout_t timeout)
119{
120 return input_report(dev, INPUT_EV_ABS, code, value, sync, timeout);
121}
122
131
137 const struct device *dev;
139 void (*callback)(struct input_event *evt, void *user_data);
142};
143
151#define INPUT_CALLBACK_DEFINE_NAMED(_dev, _callback, _user_data, name) \
152 static const STRUCT_SECTION_ITERABLE(input_callback, \
153 _input_callback__##name) = { \
154 .dev = _dev, \
155 .callback = _callback, \
156 .user_data = _user_data, \
157 }
158
170#define INPUT_CALLBACK_DEFINE(_dev, _callback, _user_data) \
171 INPUT_CALLBACK_DEFINE_NAMED(_dev, _callback, _user_data, _callback)
172
176
177#ifdef __cplusplus
178}
179#endif
180
182
183#endif /* ZEPHYR_INCLUDE_INPUT_INPUT_H_ */
Macros for declaring and defining dedicated workqueues.
#define K_DEDICATED_WORK_QUEUE_DECLARE(_prefix, _module)
Declare workqueue helper functions for a subsystem.
Definition dedicated_workq.h:101
APIs and macros for the Zephyr device model.
#define INPUT_EV_REL
Relative coordinate event.
Definition input-event-codes.h:26
#define INPUT_EV_KEY
Key event.
Definition input-event-codes.h:25
#define INPUT_EV_ABS
Absolute coordinate event.
Definition input-event-codes.h:27
bool input_queue_empty(void)
Returns true if the input queue is empty.
static int input_report_key(const struct device *dev, uint16_t code, int32_t value, bool sync, k_timeout_t timeout)
Report a new INPUT_EV_KEY input event, note that value is converted to either 0 or 1.
Definition input.h:92
static int input_report_abs(const struct device *dev, uint16_t code, int32_t value, bool sync, k_timeout_t timeout)
Report a new INPUT_EV_ABS input event.
Definition input.h:116
int input_report(const struct device *dev, uint8_t type, uint16_t code, int32_t value, bool sync, k_timeout_t timeout)
Report a new input event.
static int input_report_rel(const struct device *dev, uint16_t code, int32_t value, bool sync, k_timeout_t timeout)
Report a new INPUT_EV_REL input event.
Definition input.h:104
Public kernel APIs.
__INT32_TYPE__ int32_t
Definition stdint.h:74
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:543
Input callback structure.
Definition input.h:135
void(* callback)(struct input_event *evt, void *user_data)
The callback function.
Definition input.h:139
void * user_data
User data pointer.
Definition input.h:141
const struct device * dev
device pointer or NULL.
Definition input.h:137
Input event structure.
Definition input.h:48
uint8_t sync
Sync flag.
Definition input.h:52
const struct device * dev
Device generating the event or NULL.
Definition input.h:50
uint16_t code
Event code (see INPUT_KEY_CODES, INPUT_BTN_CODES, INPUT_ABS_CODES, INPUT_REL_CODES,...
Definition input.h:59
int32_t value
Event value.
Definition input.h:61
uint8_t type
Event type (see INPUT_EV_CODES).
Definition input.h:54
Kernel timeout type.
Definition clock.h:65
Iterable sections helpers.