Zephyr API Documentation 3.7.99
A Scalable Open Source RTOS
|
Input Interface . More...
Topics | |
Input Event Definitions | |
Data Structures | |
struct | input_event |
Input event structure. More... | |
struct | input_callback |
Input callback structure. More... | |
Macros | |
#define | INPUT_CALLBACK_DEFINE_NAMED(_dev, _callback, _user_data, name) |
Register a callback structure for input events with a custom name. | |
#define | INPUT_CALLBACK_DEFINE(_dev, _callback, _user_data) |
Register a callback structure for input events. | |
Functions | |
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_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. | |
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. | |
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. | |
bool | input_queue_empty (void) |
Returns true if the input queue is empty. | |
int16_t | input_to_hid_code (uint16_t input_code) |
Convert an input code to HID code. | |
uint8_t | input_to_hid_modifier (uint16_t input_code) |
Convert an input code to HID modifier. | |
Input Interface .
#define INPUT_CALLBACK_DEFINE | ( | _dev, | |
_callback, | |||
_user_data ) |
#include <zephyr/input/input.h>
Register a callback structure for input events.
The _dev
field can be used to only invoke callback for events generated by a specific device. Setting dev to NULL causes callback to be invoked for every event.
_dev | device pointer or NULL. |
_callback | The callback function. |
_user_data | Pointer to user specified data. |
#define INPUT_CALLBACK_DEFINE_NAMED | ( | _dev, | |
_callback, | |||
_user_data, | |||
name ) |
#include <zephyr/input/input.h>
Register a callback structure for input events with a custom name.
Same as INPUT_CALLBACK_DEFINE but allows specifying a custom name for the callback structure. Useful if multiple callbacks are used for the same callback function.
bool input_queue_empty | ( | void | ) |
#include <zephyr/input/input.h>
Returns true if the input queue is empty.
This can be used to batch input event processing until the whole queue has been emptied. Always returns true if CONFIG_INPUT_MODE_SYNCHRONOUS
is enabled.
int input_report | ( | const struct device * | dev, |
uint8_t | type, | ||
uint16_t | code, | ||
int32_t | value, | ||
bool | sync, | ||
k_timeout_t | timeout ) |
#include <zephyr/input/input.h>
Report a new input event.
This causes all the callbacks for the specified device to be executed, either synchronously or through the input thread if utilized.
dev | Device generating the event or NULL. |
type | Event type (see INPUT_EV_CODES). |
code | Event code (see INPUT_KEY_CODES, INPUT_BTN_CODES, INPUT_ABS_CODES, INPUT_REL_CODES, INPUT_MSC_CODES). |
value | Event value. |
sync | Set the synchronization bit for the event. |
timeout | Timeout for reporting the event, ignored if CONFIG_INPUT_MODE_SYNCHRONOUS is used. |
0 | if the message has been processed. |
negative | if CONFIG_INPUT_MODE_THREAD is enabled and the message failed to be enqueued. |
|
inlinestatic |
#include <zephyr/input/input.h>
Report a new INPUT_EV_ABS input event.
< Absolute coordinate event
|
inlinestatic |
#include <zephyr/input/input.h>
Report a new INPUT_EV_KEY input event, note that value is converted to either 0 or 1.
< Key event
|
inlinestatic |
#include <zephyr/input/input.h>
Report a new INPUT_EV_REL input event.
< Relative coordinate event
#include <zephyr/input/input_hid.h>
Convert an input code to HID code.
Takes an input code as input and returns the corresponding HID code as output. The return value is -1 if the code is not found, if found it can safely be casted to a uint8_t type.
input_code | Event code (see INPUT_KEY_CODES). |
the | HID code corresponding to the input code. |
-1 | if there's no HID code for the specified input code. |
#include <zephyr/input/input_hid.h>
Convert an input code to HID modifier.
Takes an input code as input and returns the corresponding HID modifier as output or 0.
input_code | Event code (see INPUT_KEY_CODES). |
the | HID modifier corresponding to the input code. |
0 | if there's no HID modifier for the specified input code. |