29.07.2011 - fundamental new
This commit is contained in:
@@ -3,22 +3,37 @@
|
||||
|
||||
#include "pithread.h"
|
||||
#ifndef __WIN32__
|
||||
#include <termios.h>
|
||||
# include <termios.h>
|
||||
#endif
|
||||
|
||||
#define WAIT_FOR_EXIT while (!PIKbdListener::exiting) msleep(1);
|
||||
|
||||
typedef void (*KBFunc)(char, void * );
|
||||
|
||||
class PIKbdListener: public PIThread {
|
||||
friend class PIConsole;
|
||||
public:
|
||||
// slot is any function format "void <func>(char, void * )"
|
||||
PIKbdListener(KBFunc slot = 0, void * data = 0);
|
||||
~PIKbdListener();
|
||||
~PIKbdListener() {terminate(); end();}
|
||||
|
||||
inline void enableExitCapture(char key = 'Q') {exit_enabled = true; exit_key = key;}
|
||||
inline void disableExitCapture() {exit_enabled = false;}
|
||||
inline bool exitCaptured() const {return exit_enabled;}
|
||||
inline char exitKey() const {return exit_key;}
|
||||
inline bool isActive() {return is_active;}
|
||||
inline void setActive(bool yes = true) {is_active = yes;}
|
||||
|
||||
static bool exiting;
|
||||
|
||||
private:
|
||||
void begin();
|
||||
void run();
|
||||
void end();
|
||||
|
||||
KBFunc ret_func;
|
||||
char rc;
|
||||
char rc, exit_key, is_active;
|
||||
bool exit_enabled;
|
||||
void * data;
|
||||
#ifdef __WIN32__
|
||||
DWORD ret;
|
||||
|
||||
Reference in New Issue
Block a user