Zephyr API Documentation
3.6.99
A Scalable Open Source RTOS
|
Input Interface. More...
Modules | |
Input Event Definitions | |
Data Structures | |
struct | input_event |
Input event structure. More... | |
struct | input_callback |
Input callback structure. More... | |
Macros | |
#define | INPUT_CALLBACK_DEFINE(_dev, _callback) |
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 | |||
) |
#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. |
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.
|
inlinestatic |
#include <zephyr/input/input.h>
Report a new INPUT_EV_KEY input event, note that value is converted to either 0 or 1.
|
inlinestatic |
#include <zephyr/input/input.h>
Report a new INPUT_EV_REL input 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. |