代码拉取完成,页面将自动刷新
#include "sdl_lcd.h"
#include "sc_gui.h"
#include "sc_event_task.h"
#include "sc_arc.h"
int tick_thread(void * data);
int get_sdl2_key(void)
{
int key=0;
SDL_Event evt;
while (SDL_PollEvent(&evt) != 0)
{
//event.type存储了当前的事件类型
//如果无键盘鼠标 触摸点击 那么 默认是 0x200
switch (evt.type)
{
case SDL_KEYDOWN:
printf("\nk=%s", SDL_GetKeyName(evt.key.keysym.sym));
const Uint8 *state = SDL_GetKeyboardState(NULL);
if ( state[SDL_SCANCODE_UP]) sc_send_event(KEY_EVENT_UP);
if ( state[SDL_SCANCODE_DOWN] ) sc_send_event(KEY_EVENT_DP);
if ( state[SDL_SCANCODE_LEFT] ) sc_send_event(KEY_EVENT_L);
if ( state[SDL_SCANCODE_RIGHT]) sc_send_event(KEY_EVENT_R);
if ( state[SDL_SCANCODE_BACKSPACE]) sc_send_event(KEY_EVENT_BLACK);//返回
if ( state[SDL_SCANCODE_RETURN]) sc_send_event(KEY_EVENT_OK);//回车
if ( state[SDL_SCANCODE_KP_MINUS]) sc_send_event(KEY_EVENT_VOLP);//返回
if ( state[SDL_SCANCODE_KP_PLUS]) sc_send_event(KEY_EVENT_VOLN);//回车
if ( state[SDL_SCANCODE_0] )key='0';
if ( state[SDL_SCANCODE_1] )key='1';
if ( state[SDL_SCANCODE_2] )key='2';
if ( state[SDL_SCANCODE_3] )key='3';
if ( state[SDL_SCANCODE_4] )key='4';
if ( state[SDL_SCANCODE_5] )key='5';
if ( state[SDL_SCANCODE_6] )key='6';
if ( state[SDL_SCANCODE_7] )key='7';
if ( state[SDL_SCANCODE_8] )key='8';
if ( state[SDL_SCANCODE_9] )key='9';
if ( state[SDL_SCANCODE_A]) key='~';
if ( state[SDL_SCANCODE_S]) key='+';
if ( state[SDL_SCANCODE_D]) key='-';
if ( state[SDL_SCANCODE_F]) key='*';
if ( state[SDL_SCANCODE_G]) key='/';
if ( state[SDL_SCANCODE_PAGEDOWN]) key='O';
if ( state[SDL_SCANCODE_PAGEUP]) key='B';
if ( state[SDL_SCANCODE_DELETE]) key='d'; //删除
// Menu_Put_Event(k);
case SDL_KEYUP:
break;
case SDL_TEXTINPUT:
//如果是文本输入 输出文本
// PrintText(event.text.text);
break;
//case SDL_MOUSEBUTTONDOWN:
/* 如果有任何鼠标点击消息 或者SDL_QUIT消息 那么将退出窗口 */
case SDL_QUIT:
return -1;
break;
default:
break;
}
}
// if(key) sc_send_event(key);
return 0;
}
void demo_test(void);
extern lv_font_t myFont_14;
int main(int argc,char* args[])
{
// printf("中文编码测试\r\n");
if (!init_SDL2()) return -1;
SDL_CreateThread(tick_thread, "tick", NULL); //定时线程
//-----------------------------------
SC_GUI_Init(SDL_DrawPoint,C_BLACK,C_WHITE,C_RED,C_RED,(lv_font_t*)&myFont_14);
demo_test();
SC_Show_str(0,0,0,0,"#0xf006# #0xf006# #0xf006#123",0,gui->font);
while (1)
{
if(g_tick%10==0)
{
up_lcd();
}
g_tick++;
SDL_Delay(1); /*Sleep for 5 millisecond*/
sc_task_loop();
if(get_sdl2_key()==-1)
{
return -1;
}
}
close_SDL2();
return 0;
}
//中断函数模拟5ms
int tick_thread(void * data)
{
(void)data;
while(1)
{
SDL_Delay(5); /*Sleep for 5 millisecond*/
}
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。