#include
#include
#include
#include
#include
#include
#include
#include
#include
Int reportkey (int fd, uint16_t type, uint16_t keycode, int32_t value)
{
Int ret.
Struct input_event ev.
Memset (& amp; Ev, 0, sizeof (struct input_event));
Ev. Type=type;
Ev. Code=keycode;
Ev. Value=https://bbs.csdn.net/topics/value;
Ret=write (fd, & amp; Ev, sizeof (struct input_event));
If (ret & lt; 0 {
Printf (" report key error! \n");
return ret;
}
/* printf (" \ n key is % d % d ", keycode, value); */
return 0;
}
Int main (void)
{
Struct uinput_user_dev uidev;
Int fd, ret;
Fd=open ("/dev/uinput O_WRONLY | O_NONBLOCK);
If (fd & lt; 0 {
Return fd.
}
//configuration device properties
The ioctl (fd, UI_SET_EVBIT EV_ABS);//support touch
The ioctl (fd, UI_SET_EVBIT EV_SYN);//support synchronization, is used to report
//Touch
The ioctl (fd, UI_SET_EVBIT EV_ABS);//support touch
The ioctl (fd, UI_SET_ABSBIT ABS_MT_SLOT);
The ioctl (fd, UI_SET_ABSBIT ABS_MT_TOUCH_MAJOR);
The ioctl (fd, UI_SET_ABSBIT ABS_MT_POSITION_X);
The ioctl (fd, UI_SET_ABSBIT ABS_MT_POSITION_Y);
The ioctl (fd, UI_SET_ABSBIT ABS_MT_TRACKING_ID);
The ioctl (fd, UI_SET_ABSBIT ABS_MT_PRESSURE);
The ioctl (fd, UI_SET_PROPBIT INPUT_PROP_DIRECT);
Memset (& amp; Uidev, 0, sizeof (struct uinput_user_dev));
Snprintf (uidev. Name, UINPUT_MAX_NAME_SIZE, "uinput - xiaohei");
Uidev. Id. Bustype=BUS_USB;
Uidev. Id. Vendor=0 x1234;
Uidev. Id. The product=0 xfedc;
Uidev. Id. Version=1;
Uidev. Absmin [ABS_MT_POSITION_X]=0;
Uidev. Absmax [ABS_MT_POSITION_X]=1920;//coordinates x's biggest
Uidev. Absfuzz [ABS_MT_POSITION_X]=0;
Uidev. Absflat [ABS_MT_POSITION_X]=0;
Uidev. Absmin [ABS_MT_POSITION_Y]=0;
Uidev. Absmax [ABS_MT_POSITION_Y]=1080;//y coordinate of the
Uidev. Absfuzz [ABS_MT_POSITION_Y]=0;
Uidev. Absflat [ABS_MT_POSITION_Y]=0;
Uidev. Absmin [ABS_MT_PRESSURE]=0;
Uidev. Absmax [ABS_MT_PRESSURE]=100;//touch pressure maximum minimum
Uidev. Absfuzz [ABS_MT_PRESSURE]=0;
Uidev. Absflat [ABS_MT_PRESSURE]=0;
Uidev. Absmax [ABS_MT_SLOT]=9;//at the same time support up to nine contact
Uidev. Absmax [ABS_MT_TOUCH_MAJOR]=16;//and screen interface maximum
Uidev. Absmax [ABS_MT_TRACKING_ID]=65535;//key code ID maximum cumulative overlay
Ret=write (fd, & amp; Uidev, sizeof (struct uinput_user_dev));
Ret=ioctl (fd, UI_DEV_CREATE);
If (ret & lt; 0 {
Close (fd);
return ret;
}
While (1) {
Reportkey (fd, 3,47,5);
Reportkey (fd, 3,57,101);
Reportkey (fd, 3,58,1000);
Reportkey (fd, 1330, 1);
Reportkey (fd, 3,53,600);
Reportkey (fd, 3,54,600);
Reportkey (fd, 0, 0);
Reportkey (fd, 3,47,5);
Reportkey (fd, 3,53,900);
Reportkey (fd, 3,54,900);
Reportkey (fd, 0, 0);
Reportkey (fd, 3,47,5);
Reportkey (fd, 3,57,101);
Reportkey (fd, 3,58,0);
Reportkey (fd, 3,57,4294967295);
Reportkey (fd, 0, 0);
Sleep (1);
}
The ioctl (fd, UI_DEV_DESTROY);
Close (fd);
return 0;
}