From 8ac651b10ded1f6583d069c53d0c35dfafc80a0b Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Sat, 10 Feb 2024 15:02:28 +0000 Subject: [PATCH] doc: input: add two paragraphs about keymap and hid mapping Add a paragraph about the input-keymap binding and one about the HID mapping functions. Signed-off-by: Fabio Baltieri --- doc/services/input/gpio-kbd.rst | 32 ++++++++++++++++++++++++++++++++ doc/services/input/index.rst | 8 ++++++++ 2 files changed, 40 insertions(+) diff --git a/doc/services/input/gpio-kbd.rst b/doc/services/input/gpio-kbd.rst index 2910405bdd2..162e7cb9740 100644 --- a/doc/services/input/gpio-kbd.rst +++ b/doc/services/input/gpio-kbd.rst @@ -199,6 +199,38 @@ The actual key mask can be changed at runtime by enabling :kconfig:option:`CONFIG_INPUT_KBD_ACTUAL_KEY_MASK_DYNAMIC` and the using the :c:func:`input_kbd_matrix_actual_key_mask_set` API. +Keymap configuration +******************** + +Keyboard matrix devices report a series of x/y/touch events. These can be +mapped to normal key events using the :dtcompatible:`input-keymap` driver. + +For example, the following would setup a ``keymap`` device that take the +x/y/touch events as an input and generate corresponding key events as an +output: + +.. code-block:: devicetree + + kbd { + ... + keymap { + compatible = "input-keymap"; + keymap = < + MATRIX_KEY(0, 0, INPUT_KEY_1) + MATRIX_KEY(0, 1, INPUT_KEY_2) + MATRIX_KEY(0, 2, INPUT_KEY_3) + MATRIX_KEY(1, 0, INPUT_KEY_4) + MATRIX_KEY(1, 1, INPUT_KEY_5) + MATRIX_KEY(1, 2, INPUT_KEY_6) + MATRIX_KEY(2, 0, INPUT_KEY_7) + MATRIX_KEY(2, 1, INPUT_KEY_8) + MATRIX_KEY(2, 2, INPUT_KEY_9) + >; + row-size = <3>; + col-size = <3>; + }; + }; + Keyboard matrix shell commands ****************************** diff --git a/doc/services/input/index.rst b/doc/services/input/index.rst index 01d7d92b088..a5f28d90fe5 100644 --- a/doc/services/input/index.rst +++ b/doc/services/input/index.rst @@ -55,6 +55,14 @@ footprint, or in a complex application with an existing event model, where the callback is just a wrapper to pipe back the event in a more complex application specific event system. +HID code mapping +**************** + +A common use case for input devices is to use them to generate HID reports. For +this purpose, the :c:func:`input_to_hid_code` and +:c:func:`input_to_hid_modifier` functions can be used to map input codes to HID +codes and modifiers. + Kscan Compatibility *******************