#include <stdio.h>
#include <unistd.h>
#include <linux/input.h>
#include <linux/uinput.h>
#include "fakedev.h"
int dummy_setup(struct uinput_user_dev *dev, int fd)
{
if (ioctl(fd, UI_SET_EVBIT, EV_KEY) == -1) goto error;
if (ioctl(fd, UI_SET_EVBIT, EV_REL) == -1) goto error;
if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
if (ioctl(fd, UI_SET_KEYBIT, BTN_LEFT) == -1) goto error;
if (ioctl(fd, UI_SET_KEYBIT, BTN_MIDDLE) == -1) goto error;
if (ioctl(fd, UI_SET_KEYBIT, BTN_RIGHT) == -1) goto error;
if (ioctl(fd, UI_SET_RELBIT, REL_X) == -1) goto error;
if (ioctl(fd, UI_SET_RELBIT, REL_Y) == -1) goto error;
return 0;
error:
perror("ioctl failed.");
return -1;
}
int dummy_run(int fd)
{
usleep(1000);
return 0;
}
struct test_device dummy_dev = {
.name = "dummy_ test device",
.setup = dummy_setup,
.run = dummy_run,
};
struct test_device* get_device()
{
return &dummy_dev;
}