diff options
-rw-r--r-- | cInput.cpp | 7 | ||||
-rw-r--r-- | cInput.h | 1 | ||||
-rw-r--r-- | main.cpp | 6 |
3 files changed, 12 insertions, 2 deletions
@@ -45,8 +45,11 @@ sInputEvent cInput::poll() return ret; read (STDIN_FILENO, &buff, 1); - - if (buff[0] == '\x1B') //Escape sequence + if (buff[0] == 3) { + // User pressd Ctr+C + ret.type = _EVENT_TERM; + } + else if (buff[0] == '\x1B') //Escape sequence { read (STDIN_FILENO, &buff, 5); if(buff[0] == '[') @@ -23,6 +23,7 @@ #define _EVENT_CHAR 1 #define _EVENT_KEY 2 #define _EVENT_MOUSE 3 +#define _EVENT_TERM 4 struct sInputEvent { @@ -42,10 +42,16 @@ int main() pos.x = ie.x; pos.y = ie.y; } + else if (ie.type == _EVENT_TERM) + { + return 0; + } a.clear(); a.drawPoint('X', pos, true, _COL_GREEN); a.render(); + + usleep(10*1000); } } |