我找了半天没看懂DEMO.
就是比如我
```
DWORD WINAPI taskKeyBoard(LPVOID pragma)
{
(void)pragma;
int ch;
while (1)
{
if (_kbhit())
{ //如果有按键按下,则_kbhit()函数返回真
ch = _getch(); //使用_getch()函数获取按下的键值
std::cout << ch << std::endl;
if (ch == 27)
break;
}
Sleep(10); /*Just to let the system breath*/
}
}
```
我是WIN10 SIM .想键盘按1 切换到 一个界面 按2 切换到一个界面.
就这么简单的一个键盘检测 或者std::cin>>
我试了下都没用的.
然后看 keyborad.h
看不懂他到底要干嘛.我没SDL的编程基础...
希望各位大神指点下.
最近编辑记录 3038922 (2020-02-06 19:19:42)
离线
我仔细看了一下这个demo项目, 确实没有初始化keyboard驱动:
https://github.com/littlevgl/lv_sim_eclipse_sdl/blob/master/main.c
但是,他已注册mouse驱动:
/* Add the mouse as input device
* Use the 'mouse' driver which reads the PC's mouse*/
mouse_init();
lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = mouse_read; /*This function will be called periodically (by the library) to get the mouse position and state*/
lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv);
所以, 可以一葫芦画瓢把 SDL 模拟器 keyboard驱动初始化加到上面的代码下面:
https://github.com/littlevgl/lv_drivers/blob/master/indev/keyboard.c
添加注册键盘驱动:
#if USE_KEYBOARD
keyboard_init(); //键盘初始化
lv_indev_drv_t sdl_kb_drv;
lv_indev_drv_init(&sdl_kb_drv);
sdl_kb_drv.type = LV_INDEV_TYPE_KEYPAD;
sdl_kb_drv.read_cb = keyboard_read; //每个gui时间片轮询都会调用此回调函数
lv_indev_t * sdl_kb_indev = lv_indev_drv_register(&sdl_kb_drv);
#endif
离线
已经完成 谢谢哈
离线
已经完成 谢谢哈
恭喜恭喜, 可以分享一下吗?
离线
恭喜恭喜, 可以分享一下吗?
离线