libevdev-uinput.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2013 Red Hat, Inc.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this software and associated documentation files (the "Software"), to
7  * deal in the Software without restriction, including without limitation the
8  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9  * sell copies of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  */
24 
25 #ifndef LIBEVDEV_UINPUT_H
26 #define LIBEVDEV_UINPUT_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <libevdev/libevdev.h>
33 
34 struct libevdev_uinput;
35 
111  /* intentionally -2 to avoid code like below from accidentally working:
112  fd = open("/dev/uinput", O_RDWR); // fails, fd is -1
113  libevdev_uinput_create_from_device(dev, fd, &uidev); // may hide the error */
115 };
116 
154 int libevdev_uinput_create_from_device(const struct libevdev *dev,
155  int uinput_fd,
156  struct libevdev_uinput **uinput_dev);
157 
169 void libevdev_uinput_destroy(struct libevdev_uinput *uinput_dev);
170 
184 int libevdev_uinput_get_fd(const struct libevdev_uinput *uinput_dev);
185 
210 const char* libevdev_uinput_get_syspath(struct libevdev_uinput *uinput_dev);
211 
232 const char* libevdev_uinput_get_devnode(struct libevdev_uinput *uinput_dev);
233 
248 int libevdev_uinput_write_event(const struct libevdev_uinput *uinput_dev,
249  unsigned int type,
250  unsigned int code,
251  int value);
252 #ifdef __cplusplus
253 }
254 #endif
255 
256 #endif /* LIBEVDEV_UINPUT_H */
int libevdev_uinput_write_event(const struct libevdev_uinput *uinput_dev, unsigned int type, unsigned int code, int value)
Post an event through the uinput device.
const char * libevdev_uinput_get_devnode(struct libevdev_uinput *uinput_dev)
Return the device node representing this uinput device.
int libevdev_uinput_get_fd(const struct libevdev_uinput *uinput_dev)
Return the file descriptor used to create this uinput device.
void libevdev_uinput_destroy(struct libevdev_uinput *uinput_dev)
Destroy a previously created uinput device and free associated memory.
const char * libevdev_uinput_get_syspath(struct libevdev_uinput *uinput_dev)
Return the syspath representing this uinput device.
int libevdev_uinput_create_from_device(const struct libevdev *dev, int uinput_fd, struct libevdev_uinput **uinput_dev)
Create a uinput device based on the given libevdev device.
libevdev_uinput_open_mode
Definition: libevdev-uinput.h:110
@ LIBEVDEV_UINPUT_OPEN_MANAGED
let libevdev open and close /dev/uinput
Definition: libevdev-uinput.h:114