How to simulate button input and mouse simulation in linux
Source: Internet
Author: User
In linux, how does one simulate key input and mouse input? Linux general technology-Linux programming and kernel information. The following is a detailed description. View the type of/dev/input/eventX events, cat/proc/bus/input/devices
The device has its own special key code, I need to be some standard keys, such as 0-9, X-Z analog into a standard button, such as KEY_0, KEY-Z, so need to use the key simulation, the specific method is to operate the/dev/input/event1 file and write an input_event struct to it to simulate the input of the key.
Linux/input. h is defined. This file also defines the encoding of standard keys.
Struct input_event {
Struct timeval time; // key time
_ 2010type; // type, which is defined below
_ Code; // the buttons to simulate
_ S32 value; // whether to press or release
};
Code:
Event code. If the event type code is EV_KEY, the code is the device keyboard code. The code is 0 ~ 127 is the key code on the keyboard, 0x110 ~ 0x116 indicates the code on the mouse. 0x110 (BTN _ LEFT) indicates the LEFT mouse button, 0x111 (BTN_RIGHT) indicates the right mouse button, and 0x112 indicates the BTN _ MIDDLE) in the left-side navigation pane. for other code meanings, see include/linux/input. h file. if the event type code is EV_REL, the code value indicates the trajectory type. for example, it indicates the x-axis direction of the mouse (Code: 0x00) and the y-axis direction of the mouse (Code: 0x01 ), indicates the direction of the wheel in the mouse (Code: 0x08 ).
Type:
EV_KEY, keyboard
EV_REL, Relative Coordinate
EV_ABS, absolute Coordinate
Value:
Event value. if the event type code is EV_KEY, when the press key value is 1, the release value is 0; if the event type code is EV _ REL, the positive and negative values of value represent two values in different directions.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service