Use an explicit callback name so that multiple instances of this do not
result in a:
redefinition of '_input_callback__longpress_cb'
error. This used to work when it was using unique generated wrappers,
but now it needs an index in the callback name.
Use it in one of the API tests as well, just in case.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add a void *user_data pointer to the input callback structure. This is
useful for driver to get back the driver data structure and avoid
defining wrapper functions.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Change the input callback function name to make it easier to identify
what it belongs to. This clears some ambiguity when observing the symbol
names corresponding to the function pointers in the callback section.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Rename the internal input callback structure to input_callback. This is
for coherency with "INPUT_CALLBACK_DEFINE" and other similar code paths
in Zephyr, and also to avoid confusion with terminology.
This is an internal structure, applications should not have any
references to it so there should be no need for any release note
entries.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
The default 512 bytes stack size is a bit tight for some architecture
and leads to samples running out of stack. Let's default to 1024 and let
the user tweak it down if necessary.
Suggested-by: Benjamin Cabé <benjamin@zephyrproject.org>
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This driver really needs a device associated with it for the
syncronization bit to make sense, and since the argument is DT_PARENT it
will get it all the time, so no changes in practice, but this should
have been using the normal macro anyway.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add a pair of functions to translate from input events to hid codes,
mapping most of the current hid codes defined in zephyr/usb/class/hid.h.
Use a sparse table for the mapping, which takes advantage of the fact
that code 0 is reserved. Inspired by the linux equivalent hid to input
map:
https://elixir.bootlin.com/linux/latest/source/drivers/hid/hid-input.c#L27
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Change row and col static types to unsigned, this should prevent really
bad things from happening if a negative number ends up there for
whatever reasons without having to explicitly check for < 0.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
The entries pointer does not change, no need to have it in RAM, 4 bytes
saved. Refactor the init macro a bit while at it.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add a "input kbd_matrix_state" shell command. This prints the state of
a keyboard matrix in a much more compact representation than the normal
input event dump, but also keeps track of any key seen during the
execution and reports that on the "off" command. The output can be used
to help setting the actual-key-mask property.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
By making short inputs optional, the user can bypass short-events all
together if necessary (e.g. custom button-press listener).
Signed-off-by: Juliane Schulze <juliane.schulze@deveritec.com>
Fix few instances of delayable work handlers using the k_work pointer
directly in a CONTAINER_OF pointing to a k_work_delayable.
This is harmless since the k_work is the first element in
k_work_delayable, but using k_work_delayable_from_work is the right way
of handling it.
Change a couple of explicit CONTAINER_OF doing the same work as the
macro in the process.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Looking back at the current INPUT_LISTENER_CB_DEFINE api naming, it
feels like it's a bit overloaded. Rename it to a simpler
INPUT_CALLBACK_DEFINE.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add two input subsystem options: one for dumping input events, one for
triggering input reports from the shell.
The two are independent from each other, so dumping can be enabled on
any application that has no shell, but if the shell command is present
logging can be toggled on and off with a shell command.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Add an input device to take input key events as an input and generates
short press or long press devices as output.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Move the input listener section declaration in common-rom-misc.ld
instead of using a custom input.ld file. This seems to be the common
practice for upstream iterable sections and seems to solve a
compatibility issue where the section was getting allocated incorrectly
on esp32 based platforms.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Initial commit introducing the input subsystem into Zephyr.
Includes the input_event data structure, the input_report_* APIs, an
iterables sections based subscription API and two operation modes:
synchronous, where the listeners are called directly, and asynchronous,
where the listeners are called in a dedicated thread.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>