xref: /aosp_15_r20/external/ltp/include/tst_uinput.h (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2019 Cyril Hrubis <[email protected]>
4  */
5 
6 #ifndef TST_UINPUT_H__
7 #define TST_UINPUT_H__
8 
9 /**
10  * Tries to open the uinput device.
11  *
12  * Returns file descriptor on success, -1 on failure.
13  */
14 int open_uinput(void);
15 
16 /**
17  * Creates virtual input device.
18  *
19  * @fd File descriptor returned by open_uinput().
20  */
21 void create_input_device(int fd);
22 
23 /**
24  * Parses /proc/bus/input/devices and returns the strings for our virtual device.
25  * If passing 'H' to it, it returns HANDLERS string. If passing 'S' to it, it
26  * returns SYSFS string.
27  *
28  * Returns newly allocated string, or NULL in a case of failure.
29  */
30 char *get_input_field_value(char field);
31 
32 /**
33  * Sets up the virtual device to appear as a mouse, this must be called before
34  * the call to create_input_device().
35  *
36  * @fd File descriptor as returned by open_uinput().
37  */
38 void setup_mouse_events(int fd);
39 
40 /**
41  * Destroys virtual input device.
42  *
43  * @fd File descriptor returned by open_uinput().
44  */
45 void destroy_input_device(int fd);
46 
47 #endif	/* TST_UINPUT_H__ */
48