Added evsend command
This commit is contained in:
parent
487ff84db8
commit
42634b072c
1 changed files with 50 additions and 0 deletions
50
tools/evsend.cpp
Normal file
50
tools/evsend.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
#include <iostream>
|
||||
#include <linux/input.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc != 5)
|
||||
{
|
||||
std::cout << "Usage: " << argv[0] << " DEVICE TYPE CODE VALUE" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* filename = argv[1];
|
||||
struct input_event event;
|
||||
event.type = atoi(argv[2]);
|
||||
event.code = atoi(argv[3]);
|
||||
event.value = atoi(argv[4]);
|
||||
|
||||
int fd = open(filename, O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
std::cout << argv[0] << ": couldn't access: " << filename << ": " << strerror(errno) << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (write(fd, &event, sizeof(event)) != sizeof(event))
|
||||
{
|
||||
std::cout << argv[0] << ": write error: " << filename << ": " << strerror(errno) << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// std::cout << "Send: Event(type: " << event.type << ", code: " << event.code << ", value: " << event.value << ")" << std::endl;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
Loading…
Reference in a new issue