-
Notifications
You must be signed in to change notification settings - Fork 0
/
1
53 lines (44 loc) · 1002 Bytes
/
1
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
#include <stdio.h>
int main()
{
char buf[16];
const char* OUTFILE = "buttonEvents.bin";
FILE* buttonEvent = fopen("/dev/input/event0", "rb");
FILE* fout;
const unsigned char SEARCH = 0xD9;
const unsigned char VOLUMEUP = 0x73;
const unsigned char VOLUMEDOWN = 0x72;
const unsigned char HOME = 0x66;
const unsigned char ENTER = 0x1C;
const unsigned char MENU = 0x8B;
const unsigned char BACK = 0x9E;
const char buttons[] = {HOME, ENTER, MENU, BACK, SEARCH, VOLUMEUP, VOLUMEDOWN};
char buttonStatus[8] = {0,0,0,0,0,0,0,0xff};
while(1)
{
if(!buttonEvent)
{
break;
}
int size;
while((size= fread(buf,1,16,buttonEvent))>=0)
{
if(size<16) continue;
if(!buttonEvent) break;
if(buf[8] != 1) continue;
int i;
for(i = 0; i < 7; i++)
{
if(buf[10] == buttons[i])
{
buttonStatus[i] = buf[12] ;
fout = fopen(OUTFILE,"wb");
fwrite(buttonStatus,1,8,fout);
fclose(fout);
}
}
}
}
fclose(buttonEvent);
return 0;
}