挖坑网/填坑网 DebugDump Forum

别人挖坑默默填上,自己挖坑含泪填上。天下没有填不了的坑,只有不会填坑的人。来吧,加入我们,挖坑行,填坑你更行! 站长QQ: 516333132 点击这里给我发消息

您尚未登录。

#1 2018-02-17 21:16:04

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,802

发现 littlevgl提供的pc_simulator的demo只能鼠标输入,不能键盘输入.

QQ20180217211322.png

我看了以下sdl monitor的代码,确实没有处理键盘输入的情况, 改天看能不能改改代码完善这个功能。

离线

#2 2018-02-18 16:29:19

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,802

Re: 发现 littlevgl提供的pc_simulator的demo只能鼠标输入,不能键盘输入.

根据 https://littlevgl.com/porting

Keypad or keyboard

indev_drv.type = LV_INDEV_TYPE_KEYPAD;
indev_drv.read_fp = my_input_read;  

The read function should look like this:

bool keyboard_read(lv_indev_data_t *data) 
{
    if(key_pressed()) {
        data->state = LV_INDEV_EVENT_PR;
        data->key = get_key();
    } else {
        data->state = LV_INDEV_EVENT_REL;
        data->key = 0;
    }

    return false;   /*No buffering so no more data read*/
} 

To use a keyboard:

LV_OBJ_GROUP has to be enabled in lv_conf.h
An object group has to be created: lv_group_create() and objects have to be added: lv_group_add_obj()
The created group has to be assigned to an input device: lv_indev_set_group(my_indev, group1);
Use LV_GROUP_KEY_... to navigate among the objects in the group

然后打开这个例程 lv_examples/lv_tests/lv_test_group/,修改部分代码,可以接受键盘输入了

离线

页脚