aboutsummaryrefslogtreecommitdiff
path: root/cInput.h
blob: 49d13b7905d8a04f12e75abe4dfe4c4cd685e115 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* cInput is responsible for Handling everything related to setting up and managing the console window
* as well as decoding keyboard and mouse events.
* Compatible with xterm compatible terminal emulators
*/

#ifndef CINPUT_H_
#define CINPUT_H_

#include <stdio.h>
#include <unistd.h>
#include <termios.h>
#include <sys/select.h>

#ifdef __linux__
#elif _WIN32
  #error "Platforn not supported"
#else
  #error "Platforn not supported"
#endif

#define _EVENT_NULL   0
#define _EVENT_CHAR   1
#define _EVENT_KEY    2
#define _EVENT_MOUSE  3
#define _EVENT_TERM   4

struct sInputEvent
{
  unsigned int type;
  unsigned char c;
  unsigned int b;
  int x, y;
};

class cInput
{
public:
  cInput();

  ~cInput();

  /** Reads inputevents
  * returns event struct
  * event queu is empty, when sInputEvent.type == _EVENT_NULL
  */
  sInputEvent poll();

private:
  struct termios original, raw;
};

#endif /* end of include guard:  */