/** 获取被按下的按键的键值(类似于getch函数) */ int LCUIKeyboard_GetKey( void ) { #ifdef LCUI_KEYBOARD_DRIVER_LINUX int k,c; static int input = 0, count = 0; ++count; /* 获取输入缓冲中的字符 */ k = fgetc(stdin); input += k; /* 如果还有字符在缓冲中 */ if(LCUIKeyboard_IsHit()) { LCUIKeyboard_GetKey(); } c = input; --count; /* 递归结束后就置0 */ if(count == 0) { input = 0; } if(c == 3) { exit(1); } return c; #else return -1; #endif }
static LCUI_BOOL LCUIKeyboard_Proc(void) { LCUI_Event event; /* 如果没有按键输入 */ if ( !LCUIKeyboard_IsHit() ) { return FALSE; } event.type = LCUI_KEYDOWN; event.key.key_code = LCUIKeyboard_GetKey(); LCUI_PushEvent( &event ); return TRUE; }
static LCUI_BOOL LCUIKeyboard_Proc(void) { LCUI_SystemEvent e; /* 如果没有按键输入 */ if ( !LCUIKeyboard_IsHit() ) { return FALSE; } e.type = LCUI_KEYDOWN; e.which = LCUIKeyboard_GetKey(); LCUI_PostEvent( &e ); return TRUE; }