-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·58 lines (51 loc) · 1.37 KB
/
main.cpp
File metadata and controls
executable file
·58 lines (51 loc) · 1.37 KB
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
57
58
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <pthread.h>
using namespace std;
short threadCount = 0;
void *playSound(void *threadid)
{
system("canberra-gtk-play -f laptop.ogg");
threadCount--;
pthread_exit(NULL);
}
void *playSound2(void *threadid)
{
system("canberra-gtk-play -f spacebarkey.ogg");
threadCount--;
pthread_exit(NULL);
}
void *playSound3(void *threadid)
{
system("canberra-gtk-play -f deletekey.ogg");
threadCount--;
pthread_exit(NULL);
}
int main()
{
FILE *fin;
char buffer[1000];
if(!(fin = popen("echo \'5 6 7 8 9 10 11 14 15 17 18\' | xargs -P0 -n1 xinput test","r")))
return 1;
pthread_t threads[1000];
while(fgets(buffer, sizeof(buffer), fin)!=NULL)
{
//space is 65 backspace is 22
string str(buffer);
if(str.find("press") != string::npos)
{
if(str.find("65") != string::npos)
pthread_create(&threads[++threadCount], NULL, playSound2, NULL);
else if(str.find("22") != string::npos)
pthread_create(&threads[++threadCount], NULL, playSound3, NULL);
else
pthread_create(&threads[++threadCount], NULL, playSound, NULL);
//cout << str << endl;
}
//memset(&buffer[0], 0, sizeof(buffer));
}
pclose(fin);
return 0;
}