This is example to find keyboard event:
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;
}
See: this and this for more details.
Also, if you get error 13 (Permission denied) error when doing open() on the device, check if group 'input' is defined for it and add your user to the group