Advertisement
Guest User

Untitled

a guest
May 5th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <fcntl.h>
  3. #include <stdio.h>
  4. #include <linux/input.h>
  5. #include <iostream>
  6. #include <fstream>
  7.  
  8. using namespace std;
  9.  
  10. int main () {
  11.  
  12.     int fd;
  13.  
  14.  
  15.     fstream txt;
  16.  
  17.     struct input_event struktura;
  18.  
  19.     txt.open("/home/lucid/Desktop/odczyt/zapisane.txt", ios::out);
  20.  
  21.     fd = open("/dev/input/event5", O_RDONLY);
  22.  
  23.     if(fd<0){
  24.         cout<<"Trzeba byc adminem"<<endl;
  25.  
  26.         return 1;
  27.     }
  28.  
  29.     while(struktura.code !=1){
  30.  
  31.     if(read(fd,&struktura, sizeof(struct input_event))<0){
  32.         cout<<"cos nie tak"<<endl;
  33.         return 1;
  34.     }
  35.  
  36.     if(struktura.type==EV_KEY){
  37.         txt << " "<<struktura.code << " " <<struktura.value << endl;
  38.  
  39.     }
  40.     }
  41.     txt.close();
  42.  
  43.     return 1;
  44.  
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement