Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. const std::string get_dev_event_kbd()
  2. {
  3. std::string sline, sdev="/dev/input/", sH="", sBEV="";
  4. std::ifstream ifs("/proc/bus/input/devices");
  5. auto trimstr=[](std::string &s)
  6. {
  7. int i=0, n=s.length(); //left
  8. while ((i<n)&&((s[i]==' ')||(s[i]=='t'))) i++;
  9. s=(i>0)?s.substr(i):s;
  10. n=s.length()-1; i=n; //right
  11. while ((i>0)&&((s[i]==' ')||(s[i]=='t')||(s[i]=='n')||(s[i]=='r'))) i--;
  12. s=(i<n)?s.substr(0,i+1):s;
  13. };
  14.  
  15. while (std::getline(ifs,sline).good())
  16. {
  17. if (sline[0]=='H')
  18. {
  19. sH=sline.substr(sline.rfind(" event"));
  20. trimstr(sH);
  21. }
  22. if (sline.substr(0,5)=="B: EV")
  23. {
  24. sBEV=sline.substr(sline.find('=')+1);
  25. trimstr(sBEV);
  26. }
  27. if (sBEV=="120013") break;
  28. }
  29. sdev+=sH;
  30. return sdev;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement