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