Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Input Interface

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.
 

Detailed Description

Input Interface.

Since
3.4
Version
0.1.0

Macro Definition Documentation

◆ INPUT_CALLBACK_DEFINE

#define INPUT_CALLBACK_DEFINE (   _dev,
  _callback 
)

#include <zephyr/input/input.h>

Value:
_input_callback__##_callback) = { \
.dev = _dev, \
.callback = _callback, \
}
#define STRUCT_SECTION_ITERABLE(struct_type, varname)
Defines a new element for an iterable section.
Definition: iterable_sections.h:216
Input callback structure.
Definition: input.h:123

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.

Parameters
_devdevice pointer or NULL.
_callbackThe callback function.

Function Documentation

◆ input_queue_empty()

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.

◆ input_report()

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.

Parameters
devDevice generating the event or NULL.
typeEvent type (see INPUT_EV_CODES).
codeEvent code (see INPUT_KEY_CODES, INPUT_BTN_CODES, INPUT_ABS_CODES, INPUT_REL_CODES, INPUT_MSC_CODES).
valueEvent value.
syncSet the synchronization bit for the event.
timeoutTimeout for reporting the event, ignored if CONFIG_INPUT_MODE_SYNCHRONOUS is used.
Return values
0if the message has been processed.
negativeif CONFIG_INPUT_MODE_THREAD is enabled and the message failed to be enqueued.

◆ input_report_abs()

static int input_report_abs ( const struct device dev,
uint16_t  code,
int32_t  value,
bool  sync,
k_timeout_t  timeout 
)
inlinestatic

#include <zephyr/input/input.h>

Report a new INPUT_EV_ABS input event.

See also
input_report() for more details.

◆ input_report_key()

static int input_report_key ( const struct device dev,
uint16_t  code,
int32_t  value,
bool  sync,
k_timeout_t  timeout 
)
inlinestatic

#include <zephyr/input/input.h>

Report a new INPUT_EV_KEY input event, note that value is converted to either 0 or 1.

See also
input_report() for more details.

◆ input_report_rel()

static int input_report_rel ( const struct device dev,
uint16_t  code,
int32_t  value,
bool  sync,
k_timeout_t  timeout 
)
inlinestatic

#include <zephyr/input/input.h>

Report a new INPUT_EV_REL input event.

See also
input_report() for more details.

◆ input_to_hid_code()

int16_t input_to_hid_code ( uint16_t  input_code)

#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.

Parameters
input_codeEvent code (see INPUT_KEY_CODES).
Return values
theHID code corresponding to the input code.
-1if there's no HID code for the specified input code.

◆ input_to_hid_modifier()

uint8_t input_to_hid_modifier ( uint16_t  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.

Parameters
input_codeEvent code (see INPUT_KEY_CODES).
Return values
theHID modifier corresponding to the input code.
0if there's no HID modifier for the specified input code.