Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const std::string get_dev_event_kbd()
- {
- std::string sline, sdev="/dev/input/", sH="", sBEV="";
- std::ifstream ifs("/proc/bus/input/devices");
- auto trimstr=[](std::string &s)
- {
- int i=0, n=s.length(); //left
- while ((i<n)&&((s[i]==' ')||(s[i]=='t'))) i++;
- s=(i>0)?s.substr(i):s;
- n=s.length()-1; i=n; //right
- while ((i>0)&&((s[i]==' ')||(s[i]=='t')||(s[i]=='n')||(s[i]=='r'))) i--;
- s=(i<n)?s.substr(0,i+1):s;
- };
- while (std::getline(ifs,sline).good())
- {
- if (sline[0]=='H')
- {
- sH=sline.substr(sline.rfind(" event"));
- trimstr(sH);
- }
- if (sline.substr(0,5)=="B: EV")
- {
- sBEV=sline.substr(sline.find('=')+1);
- trimstr(sBEV);
- }
- if (sBEV=="120013") break;
- }
- sdev+=sH;
- return sdev;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement