Commit Graph

22 Commits

Author SHA1 Message Date
Helmut Lord 15c4df0aaa input: double tap
Added input double tap psuedo device

Signed-off-by: Helmut Lord <kellyhlord@gmail.com>
2024-08-19 09:56:26 -04:00
Fabio Baltieri 61129d8fd2 input: longpress, keymap: use an explicit callback name
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>
2024-07-31 12:55:11 +02:00
Fabio Baltieri 716fa268f4 input: add a user_data pointer to the callback
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>
2024-07-31 12:55:11 +02:00
Fabio Baltieri fa6eca312f input: utils: rename the input dump callback
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>
2024-04-01 11:05:02 +01:00
Fabio Baltieri d952d6a364 input: rename the internal callback struct to input_callback
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>
2024-03-19 14:30:39 +01:00
Fabio Baltieri d123a4571a input: kbd_matrix: define PRIkbdrow coherently
It's not supposed to have the "%" in the macro, reuse the existin one
for the data type.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-03-12 19:28:40 -04:00
Fabio Baltieri 906724fb99 input: increase default stack size to 1024
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>
2024-02-28 07:45:28 -06:00
Fabio Baltieri a06b7a4676 input: keymap: use the non `_OR_NULL` DEVICE_DT_GET variant
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>
2024-01-25 16:02:16 +00:00
Fabio Baltieri 297faf71d0 input: add two input to hid code translation functions
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>
2024-01-24 10:44:40 +01:00
Fabio Baltieri 23714980b0 input: utils: fix kbd_matrix_state_log types
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>
2024-01-22 11:20:50 +00:00
Fabio Baltieri 5f989e4378 input: add a keymap driver
Add a "input-keymap" driver to translate keyboard matrix event into key
events.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-19 15:14:25 +00:00
Fabio Baltieri e11bbb829f input: longpress: move constant entries pointer to the config struct
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>
2024-01-19 13:49:43 +01:00
Fabio Baltieri e4796521f2 input: kbd_matrix: add an kbd_matrix_state shell command
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>
2023-12-08 20:16:39 +00:00
Juliane Schulze eeb6bf7dd9 input: make short-inputs optional
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>
2023-11-23 09:51:57 +00:00
Gerard Marull-Paretas 1ffacb6c3a input: longpress: use POST_KERNEL level
Because APPLICATION is going to be deleted.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-15 16:04:19 +02:00
Fabio Baltieri ec71be5d9d drivers,subsys: fix few missing k_work_delayable_from_work
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>
2023-08-28 10:12:21 +02:00
Fabio Baltieri a534169ed4 input: rename callback define macro to INPUT_CALLBACK_DEFINE
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>
2023-08-10 08:15:10 +00:00
Fabio Baltieri a22fbfd1eb input: add some basic debugging utilities
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>
2023-07-12 10:53:04 +00:00
Gerard Marull-Paretas dacb3dbfeb iterable_sections: move to specific header
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>
2023-05-22 10:42:30 +02:00
Fabio Baltieri 5b36b4fa16 input: add a longpress device
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>
2023-03-24 13:48:28 +00:00
Fabio Baltieri 9889e8e20a input: move the listener section in common-rom
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>
2023-03-20 12:56:18 -07:00
Fabio Baltieri 3386e96515 input: add input subsystem
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>
2023-03-06 11:47:32 -08:00