9.10.2011 - stable backup commit
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
bool PIKbdListener::exiting;
|
||||
|
||||
PIKbdListener::PIKbdListener(KBFunc slot, void * data_): PIThread() {
|
||||
#ifdef __WIN32__
|
||||
#ifdef WINDOWS
|
||||
hIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||
GetConsoleMode(hIn, &smode);
|
||||
#else
|
||||
@@ -22,35 +22,55 @@ PIKbdListener::PIKbdListener(KBFunc slot, void * data_): PIThread() {
|
||||
|
||||
void PIKbdListener::begin() {
|
||||
//cout << "list begin" << endl;
|
||||
#ifdef __WIN32__
|
||||
#ifdef WINDOWS
|
||||
hIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||
GetConsoleMode(hIn, &smode);
|
||||
tmode = smode;
|
||||
SetConsoleMode(hIn, ENABLE_PROCESSED_INPUT);
|
||||
#else
|
||||
struct termios term;
|
||||
tcgetattr(0, &term);
|
||||
term.c_lflag &= ~(ECHO | ICANON) | NOFLSH;
|
||||
tterm = term;
|
||||
tcsetattr(0, TCSAFLUSH, &term);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void PIKbdListener::run() {
|
||||
#ifdef __WIN32__
|
||||
#ifdef WINDOWS
|
||||
ReadConsole(hIn, &rc, 1, &ret, 0);
|
||||
#else
|
||||
ret = read(0, &rc, 1);
|
||||
#endif
|
||||
if (exit_enabled && rc == exit_key) PIKbdListener::exiting = true;
|
||||
if (ret_func != 0 && ret > 0 && is_active) ret_func(rc, data);
|
||||
if (ret_func != 0 && ret > 0) ret_func(rc, data);
|
||||
}
|
||||
|
||||
|
||||
void PIKbdListener::end() {
|
||||
//cout << "list end" << endl;
|
||||
#ifdef __WIN32__
|
||||
#ifdef WINDOWS
|
||||
SetConsoleMode(hIn, smode);
|
||||
#else
|
||||
tcsetattr(0, TCSANOW, &sterm);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void PIKbdListener::setActive(bool yes) {
|
||||
is_active = yes;
|
||||
if (is_active) {
|
||||
#ifdef WINDOWS
|
||||
SetConsoleMode(hIn, tmode);
|
||||
#else
|
||||
tcsetattr(0, TCSANOW, &tterm);
|
||||
#endif
|
||||
} else {
|
||||
#ifdef WINDOWS
|
||||
SetConsoleMode(hIn, smode);
|
||||
#else
|
||||
tcsetattr(0, TCSANOW, &sterm);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user