summaryrefslogtreecommitdiff
path: root/cInput.cpp
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2019-03-06 15:04:57 +0100
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2019-03-06 15:04:57 +0100
commitf439ae911923ee70937592b1ee535e8e8e133808 (patch)
tree7e23e023d0187caf2d81b26217b3a484bd37f799 /cInput.cpp
parent6856fcf08c8c4686ddf9e5cb60862184e15d6f0b (diff)
downloadtermgl-f439ae911923ee70937592b1ee535e8e8e133808.tar.gz
Directory updates
Moved source files to ./src and exmaple and test to ./example Updated Makefile and .doxygen to use those directorys
Diffstat (limited to 'cInput.cpp')
-rw-r--r--cInput.cpp73
1 files changed, 0 insertions, 73 deletions
diff --git a/cInput.cpp b/cInput.cpp
deleted file mode 100644
index 6384c91..0000000
--- a/cInput.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-#include "cInput.h"
-
-cInput::cInput()
-{
- // Save original serial communication configuration for stdin
- tcgetattr( STDIN_FILENO, &original);
-
- // Put stdin in raw mode so keys get through directly without
- // requiring pressing enter.
- cfmakeraw (&raw);
- tcsetattr (STDIN_FILENO, TCSANOW, &raw);
-
- // Enable mouse tracking
- write (STDOUT_FILENO, "\e[?1000h", 8);
-}
-
-cInput::~cInput()
-{
- //revert changes to console
- write (STDOUT_FILENO, "\e[?1000l", 8);
- tcsetattr (STDIN_FILENO, TCSANOW, &original);
-}
-
-sInputEvent cInput::poll()
-{
- sInputEvent ret;
- unsigned char buff [6];
-
- //setup for select
- fd_set rfds;
- struct timeval tv;
- FD_ZERO(&rfds);
- FD_SET(STDIN_FILENO, &rfds);
- tv.tv_sec = 0;
- tv.tv_usec = 0;
-
- ret.type = _EVENT_NULL;
-
- //Check for Input. return of none
- if(!select(1, &rfds, NULL, NULL, &tv))
- return ret;
-
- read (STDIN_FILENO, &buff, 1);
- 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] == '[')
- {
- if(buff[1] == 'M') //Mouse Event
- {
- ret.b = buff[2] - 32;
- ret.x = buff[3] - 32 - 1; //Console sees origin at 1,1
- ret.y = buff[4] - 32 - 1; //Program at 0,0
- ret.type = _EVENT_MOUSE;
- }
- else //e.g. Arrow Keys
- {
- ret.c = buff[1];
- ret.type = _EVENT_KEY;
- }
- }
- }
- else
- {
- ret.type = _EVENT_CHAR;
- ret.c = buff[0];
- }
- return ret;
-}