Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <linux/input.h>
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main () {
- int fd;
- fstream txt;
- struct input_event struktura;
- txt.open("/home/lucid/Desktop/odczyt/zapisane.txt", ios::out);
- fd = open("/dev/input/event5", O_RDONLY);
- if(fd<0){
- cout<<"Trzeba byc adminem"<<endl;
- return 1;
- }
- while(struktura.code !=1){
- if(read(fd,&struktura, sizeof(struct input_event))<0){
- cout<<"cos nie tak"<<endl;
- return 1;
- }
- if(struktura.type==EV_KEY){
- txt << " "<<struktura.code << " " <<struktura.value << endl;
- }
- }
- txt.close();
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement