1# Copyright 2022, Basalte bv
2# SPDX-License-Identifier: Apache-2.0
3
4description: |
5  SDL keyboard GPIO input Emulator
6
7  Simulate GPIO state/interrupts using SDL keyboard events. This node has
8  to be a child of a `zephyr,gpio-emul` compatible.
9  Add a list of scancodes for the desired keys to be mapped.
10
11  Refer to https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf
12  section Keyboard/Keypad (p53) for a list of scancode values.
13
14  The following example maps the first 3 numeric keys to GPIO pins:
15
16  /* gpio0 has to be a zephyr,gpio-emul device */
17  &gpio0 {
18    ngpios = <3>;
19
20    sdl_gpio {
21      compatible = "zephyr,gpio-emul-sdl";
22      scancodes = <30 31 32>;
23    };
24  };
25
26  keypad: keypad {
27    compatible = "gpio-keys";
28    key1: key1 {
29      gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>;
30    };
31    key1: key2 {
32      gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>;
33    };
34    key3: key3 {
35      gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
36    };
37  };
38
39  The limitations of usage are:
40  - Only active high as we don't get events for keys that aren't pressed
41  - Pressing multiple keys is best effort, state will be kept but no events
42    are generated once the last key is released
43
44compatible: "zephyr,gpio-emul-sdl"
45
46include: base.yaml
47
48properties:
49  scancodes:
50    type: array
51    required: true
52    description: |
53      An array of SDL scancodes mapped to its GPIO index
54