-
Notifications
You must be signed in to change notification settings - Fork 0
/
screenListener.cpp
57 lines (48 loc) · 1.02 KB
/
screenListener.cpp
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
54
55
56
#include <fstream>
using namespace std;
int main()
{
char buf[16];
ifstream screenEvent ("/dev/input/event1",ios::in | ios::binary);
const char* OUTFILE = "/root/screenEvents.bin";
char screenStatus[5] = {0,}; //{ Xpos_H, Xpos_L, Ypos_H, Ypos_L, Pressed }
while(1)
{
if(!screenEvent) break;
while(screenEvent.read(buf,16))
{
if(buf[8] == buf[11] == 1 && buf[10] == 0x4a)
{
if(buf[12] == 1) //Pressed
{
screenStatus[4] = 1;
}
if(buf[12] == 0) //Released
{
screenStatus[4] = 0;
}
ofstream fout (OUTFILE, ios::out | ios::binary);
fout.write(screenStatus,5);
fout.close();
}
else if(buf[8] == 3)
{
if(buf[10] == 0) //X_pos
{
screenStatus[0] = buf[13];
screenStatus[1] = buf[12];
}
else if(buf[10] == 1) //Y_pos
{
screenStatus[2] = buf[13];
screenStatus[3] = buf[12];
}
ofstream fout (OUTFILE, ios::out | ios::binary);
fout.write(screenStatus,5);
fout.close();
}
}
}
screenEvent.close();
return 0;
}