lvgl / lv_drivers

TFT and touch pad drivers for LVGL embedded GUI library
https://docs.lvgl.io/master/porting/index.html
MIT License
306 stars 314 forks source link

evdev / libinput: "full" keyboard support #153

Closed Johennes closed 3 years ago

Johennes commented 3 years ago

When using the LV_INDEV_TYPE_KEYPAD type, the evdev driver supports a limited number of keys (backspace, enter, up right, left, down). Any other keys are ignored. It would be great if the driver would handle input from a regular keyboard so that, for instance, typed characters are forwarded into a textarea.

I'm not sure if there is a better way to achieve this other than adding further cases for the relevant key codes and handling things like SHIFT manually.

Maybe ASCII characters or characters found on common US English keyboard layouts would be enough for a start as that would limit the amount of switching.

I'm curious if you'd be open to adding this to lv_drivers and would be happy to help implement it.

kisvegabor commented 3 years ago

For "normal letters" data->key = in.code; should work instead of data->key = 0; in the default branch of the switch case.

It really works only for ASCII letters. Isn't there a way to get the "real" letters, e.g. shift + a = A?

Johennes commented 3 years ago

It seems that libxkbcommon would be able to do the translation from key codes to key symbols based on the current key map. I'll have to do some more research to understand what would be required to hook into that.

Johennes commented 3 years ago

Looks like libxkbcommon is working pretty ok for me so far. We'd only have to add a config setting for the key map to use. E.g. this is what I use with my laptop keyboard:

struct xkb_rule_names names = {
    .rules = NULL,
    .model = "pc105",
    .layout = "de",
    .variant = "nodeadkeys",
    .options = NULL
};
kisvegabor commented 3 years ago

Good news! :slightly_smiling_face:

We'd only have to add a config setting for the key map to use.

Shall we add parts of this config to lv_drv_conf.h?

Johennes commented 3 years ago

Yeah, good idea. :+1:

Let me play with it some more and then I'll try to put it into a pull request.