Zephyr API Documentation  3.6.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
7#ifndef ZEPHYR_INCLUDE_INPUT_H_
8#define ZEPHYR_INCLUDE_INPUT_H_
9
19#include <stdint.h>
20#include <zephyr/device.h>
22#include <zephyr/kernel.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
38 const struct device *dev;
50};
51
70int input_report(const struct device *dev,
71 uint8_t type, uint16_t code, int32_t value, bool sync,
72 k_timeout_t timeout);
73
80static inline int input_report_key(const struct device *dev,
81 uint16_t code, int32_t value, bool sync,
82 k_timeout_t timeout)
83{
84 return input_report(dev, INPUT_EV_KEY, code, !!value, sync, timeout);
85}
86
92static inline int input_report_rel(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_REL, code, value, sync, timeout);
97}
98
104static inline int input_report_abs(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_ABS, code, value, sync, timeout);
109}
110
119
125 const struct device *dev;
127 void (*callback)(struct input_event *evt);
128};
129
140#define INPUT_CALLBACK_DEFINE(_dev, _callback) \
141 static const STRUCT_SECTION_ITERABLE(input_callback, \
142 _input_callback__##_callback) = { \
143 .dev = _dev, \
144 .callback = _callback, \
145 }
146
147#ifdef __cplusplus
148}
149#endif
150
153#endif /* ZEPHYR_INCLUDE_INPUT_H_ */
#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:80
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:104
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:92
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:399
Input callback structure.
Definition: input.h:123
void(* callback)(struct input_event *evt)
The callback function.
Definition: input.h:127
const struct device * dev
device pointer or NULL.
Definition: input.h:125
Input event structure.
Definition: input.h:36
uint8_t sync
Sync flag.
Definition: input.h:40
const struct device * dev
Device generating the event or NULL.
Definition: input.h:38
uint16_t code
Event code (see INPUT_KEY_CODES, INPUT_BTN_CODES, INPUT_ABS_CODES, INPUT_REL_CODES,...
Definition: input.h:47
int32_t value
Event value.
Definition: input.h:49
uint8_t type
Event type (see INPUT_EV_CODES).
Definition: input.h:42
Kernel timeout type.
Definition: sys_clock.h:65