|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | - | - |
| build-aux/ | | 12-May-2024 | - | 16,464 | 12,247 |
| doc/ | | 12-May-2024 | - | 29,957 | 27,966 |
| export_include/libevdev/ | | 12-May-2024 | - | 2,374 | 147 |
| include/ | | 12-May-2024 | - | 3,311 | 2,602 |
| libevdev/ | | 12-May-2024 | - | 6,141 | 2,776 |
| m4/ | | 12-May-2024 | - | 9,344 | 8,440 |
| .gitattributes | D | 12-May-2024 | 631 | 16 | 15 |
| BUILD.gn | D | 12-May-2024 | 643 | 42 | 30 |
| COPYING | D | 12-May-2024 | 1.5 KiB | 30 | 24 |
| Makefile.am | D | 12-May-2024 | 386 | 12 | 9 |
| OAT.xml | D | 12-May-2024 | 6.5 KiB | 96 | 40 |
| README.OpenSource | D | 12-May-2024 | 443 | 12 | 11 |
| README.md | D | 12-May-2024 | 2.9 KiB | 90 | 68 |
| README_zh.md | D | 12-May-2024 | 2.8 KiB | 90 | 68 |
| aclocal.m4 | D | 12-May-2024 | 62.4 KiB | 1,726 | 1,555 |
| bundle.json | D | 12-May-2024 | 926 | 34 | 34 |
| config.h.in | D | 12-May-2024 | 2.6 KiB | 112 | 80 |
| configure | D | 12-May-2024 | 456.8 KiB | 15,605 | 12,566 |
| configure.ac | D | 12-May-2024 | 5.5 KiB | 193 | 168 |
| libevdev.pc.in | D | 12-May-2024 | 227 | 11 | 9 |
| meson.build | D | 12-May-2024 | 9.1 KiB | 295 | 260 |
| meson_options.txt | D | 12-May-2024 | 370 | 13 | 12 |
README.OpenSource
1[
2 {
3 "Name":"libevdev",
4 "License":"MIT License",
5 "License File":"COPYING",
6 "Version Number":"1.10",
7 "Owner":"pengfei.hou@huawei.com",
8 "Upstream URL":"https://github.com/freedesktop/libevdev",
9 "Description": "libevdev is a wrapper library for evdev devices. it moves the common tasks when dealing with evdev devices into a library and provides a library interface to the callers, thus avoiding erroneous ioctls, et"
10 }
11]
12
README.md
1# libevdev - wrapper library for evdev input devices
2
3libevdev is a wrapper library for evdev devices. it moves the common tasks when dealing with evdev devices into a library and provides a library interface to the callers, thus avoiding erroneous ioctls, etc.
4
5The eventual goal is that libevdev wraps all ioctls available to evdev devices, thus making direct access unnecessary.
6
7
8## Directory structure
9
10```
11README.md English description
12README_zh.md Chinese description
13export_include/libevdev/ API Definition
14include/ Reference header file
15libevdev/ Encapsulation layer implementation
16README.OpenSource Open Source Description
17```
18
19## How OpenHarmony integrates libevdev
20### 1.Header file import
21```c
22#define EVDEV_H
23#include <libevdev/libevdev.h>
24```
25### 2.BUILD.gn add Reference
26```c
27public_deps += ["//third_party/libevdev:libevdev"]
28```
29### 3.Example of calling libevdev function
30```c
31// Below is a simple example that shows how libevdev could be used. This example opens a device, checks for relative axes and a left mouse button and if it finds them monitors the device to print the event.
32
33// open a device
34struct libevdev *dev = NULL;
35int fd;
36int rc = 1;
37
38fd = open("/dev/input/event0", O_RDONLY|O_NONBLOCK);
39rc = libevdev_new_from_fd(fd, &dev);
40if (rc < 0) {
41 fprintf(stderr, "Failed to init libevdev (%s)\n", strerror(-rc));
42 exit(1);
43}
44// print the device info
45printf("Input device name: \"%s\"\n", libevdev_get_name(dev));
46printf("Input device ID: bus %#x vendor %#x product %#x\n",
47 libevdev_get_id_bustype(dev),
48 libevdev_get_id_vendor(dev),
49 libevdev_get_id_product(dev));
50// hecks for relative axes and a left mouse button
51if (!libevdev_has_event_type(dev, EV_REL) ||
52 !libevdev_has_event_code(dev, EV_KEY, BTN_LEFT)) {
53 printf("This device does not look like a mouse\n");
54 exit(1);
55}
56
57 // monitors the device to print the event
58do {
59 struct input_event ev;
60 rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
61 if (rc == 0)
62 printf("Event: %s %s %d\n",
63 libevdev_event_type_get_name(ev.type),
64 libevdev_event_code_get_name(ev.type, ev.code),
65 ev.value);
66} while (rc == 1 || rc == 0 || rc == -EAGAIN);
67```
68
69## libevdev Working with documents
70
71Code gitlab https://gitlab.freedesktop.org/libevdev/libevdev.git
72
73Official API Document http://www.freedesktop.org/software/libevdev/doc/latest/
74
75Detailed API definition https://www.freedesktop.org/software/libevdev/doc/latest/libevdev_8h.html
76
77Patches https://gitlab.freedesktop.org/libevdev/libevdev/merge_requests/
78
79Bugs https://gitlab.freedesktop.org/libevdev/libevdev/issues/
80
81Questions http://lists.freedesktop.org/mailman/listinfo/input-tools
82
83
84## License
85
86See [LICENSE](MITLicense).
87
88---
89
90
README_zh.md
1# libevdev - wrapper library for evdev input devices
2
3libevdev是evdev设备的包装库。它将处理evdev设备时的常见任务移动到库中,并向调用方提供库接口,从而避免错误的ioctl等。
4
5最终目标是libevdev包装了evdev设备可用的所有ioctl,因此不需要直接访问。
6
7
8## 目录结构
9
10```
11README.md 英文说明
12README_zh.md 中文说明
13export_include/libevdev/ API定义
14include/ 引用头文件
15libevdev/ 封装层实现
16README.OpenSource 开源说明
17```
18
19## OpenHarmony如何集成libevdev
20### 1.头文件引入
21```c
22#define EVDEV_H
23#include <libevdev/libevdev.h>
24```
25### 2.BUILD.gn添加引用
26```c
27public_deps += ["//third_party/libevdev:libevdev"]
28```
29### 3.调用libevdev函数过程举例
30```c
31// 下面是一个简单的示例,展示了如何使用libevdev。此示例打开一个设备,检查相对坐标和鼠标左键,如果找到,则监听设备并打印输入事件
32
33// 打开一个输入设备
34struct libevdev *dev = NULL;
35int fd;
36int rc = 1;
37
38fd = open("/dev/input/event0", O_RDONLY|O_NONBLOCK);
39rc = libevdev_new_from_fd(fd, &dev);
40if (rc < 0) {
41 fprintf(stderr, "Failed to init libevdev (%s)\n", strerror(-rc));
42 exit(1);
43}
44// 打印输入设备信息
45printf("Input device name: \"%s\"\n", libevdev_get_name(dev));
46printf("Input device ID: bus %#x vendor %#x product %#x\n",
47 libevdev_get_id_bustype(dev),
48 libevdev_get_id_vendor(dev),
49 libevdev_get_id_product(dev));
50// 检查相对坐标和鼠标左键
51if (!libevdev_has_event_type(dev, EV_REL) ||
52 !libevdev_has_event_code(dev, EV_KEY, BTN_LEFT)) {
53 printf("This device does not look like a mouse\n");
54 exit(1);
55}
56
57 // 监听该设备并打印输入事件
58do {
59 struct input_event ev;
60 rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
61 if (rc == 0)
62 printf("Event: %s %s %d\n",
63 libevdev_event_type_get_name(ev.type),
64 libevdev_event_code_get_name(ev.type, ev.code),
65 ev.value);
66} while (rc == 1 || rc == 0 || rc == -EAGAIN);
67```
68
69## libevdev使用文档
70
71代码仓库 https://gitlab.freedesktop.org/libevdev/libevdev.git
72
73API官方文档 http://www.freedesktop.org/software/libevdev/doc/latest/
74
75API详细定义 https://www.freedesktop.org/software/libevdev/doc/latest/libevdev_8h.html
76
77补丁包 https://gitlab.freedesktop.org/libevdev/libevdev/merge_requests/
78
79Bug上报 https://gitlab.freedesktop.org/libevdev/libevdev/issues/
80
81问题反馈 http://lists.freedesktop.org/mailman/listinfo/input-tools
82
83
84## License
85
86见 [LICENSE](MITLicense).
87
88---
89
90