#include <stdio.h>
#include <unistd.h>
#include <linux/input.h>
#include <linux/uinput.h>
#include "fakedev.h"
int abs_setup(struct uinput_user_dev* dev, int fd)
{
if (ioctl(fd, UI_SET_EVBIT, EV_ABS) == -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_ABSBIT, ABS_X) == -1) goto error;
if (ioctl(fd, UI_SET_ABSBIT, ABS_Y) == -1) goto error;
dev->absmin[ABS_X] = 0;
dev->absmax[ABS_X] = 120;
dev->absmin[ABS_Y] = 0;
dev->absmax[ABS_Y] = 120;
return 0;
error:
perror("ioctl failed.");
return -1;
}
int abs_run(int fd)
{
absmove(fd, 100, 100);
sleep(1);
absmove(fd, 120, 120);
sleep(1);
return 0;
}
struct test_device abs_dev = {
.name = "Abs test device",
.setup = abs_setup,
.run = abs_run,
};
struct test_device* get_device()
{
return &abs_dev;
}