Skip to content

Commit

Permalink
EGE/src/ege/global.cpp: 简化 getch 函数的实现。
Browse files Browse the repository at this point in the history
Signed-off-by: FrankHB <frankhb1989@gmail.com>
  • Loading branch information
FrankHB committed Jan 17, 2015
1 parent 3f8b41a commit bb27ec9
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions EGE/src/ege/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,30 +195,14 @@ _graph_setting::_getch()
{
if(_is_window_exit())
return grNoInitGraph;
do
{
int key;
EGEMSG msg;
unsigned long dw = GetTickCount();
do
{
key = _kbhit();
if(key < 0)
break;
if(key > 0)
if((key = _getkey_p()))
{
msg = msgkey_queue.last();
if(dw < msg.time + 1000)
{
if(((key & KEYMSG_DOWN) && (msg.wParam >= 0x70
&& msg.wParam < 0x80)) || (msg.wParam > ' '
&& msg.wParam < '0'))
key |= 0x100;
return key & 0xFFFF;
}
}
} while(_is_run() && _waitdealmessage());
}
int key = _kbhit();
if(key < 0)
break;
if(key > 0)
key = _getkey_p();
} while(_is_run() && _waitdealmessage());
return 0;
}

Expand Down

0 comments on commit bb27ec9

Please sign in to comment.