Codebase list libevdevplus / 630a8dd
Update upstream source from tag 'upstream/0.1.1' Update to upstream version '0.1.1' with Debian dir 6059bc683cc059db6d8f6ae6a83940ae8d613b0d Alexandre Viau 4 years ago
7 changed file(s) with 204 addition(s) and 107 deletion(s). Raw diff Collapse all Expand all
0 before_script:
1 - apt update
2 - apt install -y build-essential cmake git rpm
3
4 build:debian:9:
5 stage: build
6 image: debian:9
7 artifacts:
8 untracked: true
9 script:
10 - mkdir build
11 - cd build
12 - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS='-O1 -g' ..
13 - make
14
15 package:debian:9:
16 stage: deploy
17 dependencies:
18 - build:debian:9
19 script:
20 - cd build && make package
21 artifacts:
22 paths:
23 - "build/*.deb"
24 - "build/*.a"
25 - "build/*.so.*.*.*"
26
27 build:ubuntu:18.04:
28 stage: build
29 image: ubuntu:18.04
30 artifacts:
31 untracked: true
32 script:
33 - mkdir build
34 - cd build
35 - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS='-O1 -g' ..
36 - make
37
38 package:ubuntu:18.04:
39 stage: deploy
40 dependencies:
41 - build:ubuntu:18.04
42 script:
43 - cd build && make package
44 artifacts:
45 paths:
46 - "build/*.deb"
47 - "build/*.a"
48 - "build/*.so.*.*.*"
49
50 build:ubuntu:19.04:
51 stage: build
52 image: ubuntu:19.04
53 artifacts:
54 untracked: true
55 script:
56 - mkdir build
57 - cd build
58 - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS='-O1 -g' ..
59 - make
60
61 package:ubuntu:19.04:
62 stage: deploy
63 dependencies:
64 - build:ubuntu:19.04
65 script:
66 - cd build && make package
67 artifacts:
68 paths:
69 - "build/*.deb"
70 - "build/*.a"
71 - "build/*.so.*.*.*"
0 cmake_minimum_required(VERSION 3.8)
0 cmake_minimum_required(VERSION 3.0)
11 project(libevdevPlus)
22
33 set(CMAKE_CXX_STANDARD 11)
4 set(PROJECT_VERSION "0.1.0")
4 set(PROJECT_VERSION "0.1.1")
55 set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
66 set(CPACK_PACKAGE_VERSION_MAJOR "0")
77 set(CPACK_PACKAGE_VERSION_MINOR "1")
8 set(CPACK_PACKAGE_VERSION_PATCH "0")
8 set(CPACK_PACKAGE_VERSION_PATCH "1")
99 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An easy-to-use C++ event device library")
1010 set(CPACK_PACKAGE_CONTACT "Yuki Workshop <https://github.com/YukiWorkshop>")
1111 set(CMAKE_PROJECT_HOMEPAGE_URL "https://github.com/YukiWorkshop/libevdevPlus")
3434 add_executable(evdevPlus_test test.cpp)
3535 target_link_libraries(evdevPlus_test evdevPlus)
3636
37 configure_file(evdevPlus.pc.in evdevPlus.pc @ONLY)
3738 install(TARGETS evdevPlus
3839 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
3940
4041 install(TARGETS evdevPlus_Static
4142 DESTINATION ${CMAKE_INSTALL_LIBDIR})
4243
43 install(FILES evdevPlus.hpp InputEvent.hpp CommonIncludes.hpp DESTINATION include/evdevPlus/)
44 install(FILES evdevPlus.hpp InputEvent.hpp CommonIncludes.hpp DESTINATION include/evdevPlus/)
45 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/evdevPlus.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/)
1515 #include "CommonIncludes.hpp"
1616
1717 namespace evdevPlus {
18 class InputEvent {
19 public:
20 input_event event{};
18 class InputEvent {
19 public:
20 input_event event{};
2121
22 timeval &Time = event.time;
23 uint16_t &Type = event.type;
24 uint16_t &Code = event.code;
25 int32_t &Value = event.value;
22 timeval &Time = event.time;
23 uint16_t &Type = event.type;
24 uint16_t &Code = event.code;
25 int32_t &Value = event.value;
2626
27 InputEvent() = default;
27 InputEvent() = default;
2828
29 InputEvent(input_event *__event) {
30 memcpy(&event, __event, sizeof(input_event));
31 }
29 InputEvent(input_event *__event) {
30 memcpy(&event, __event, sizeof(input_event));
31 }
3232
33 InputEvent(uint16_t type, uint16_t code, uint16_t value, timeval *time = NULL) {
34 Type = type;
35 Code = code;
36 Value = value;
33 InputEvent(uint16_t type, uint16_t code, uint16_t value, timeval *time = NULL) {
34 Type = type;
35 Code = code;
36 Value = value;
3737
38 if (time)
39 memcpy(&event.time, time, sizeof(timeval));
40 }
38 if (time)
39 memcpy(&event.time, time, sizeof(timeval));
40 }
4141
42 friend void swap(InputEvent &first, InputEvent &second) {
43 using std::swap;
42 friend void swap(InputEvent &first, InputEvent &second) {
43 using std::swap;
4444
45 swap(first.event, second.event);
46 }
45 swap(first.event, second.event);
46 }
4747
48 InputEvent(InputEvent &&other) noexcept : InputEvent() {
49 swap(*this, other);
50 }
48 InputEvent(InputEvent &&other) noexcept : InputEvent() {
49 swap(*this, other);
50 }
5151
52 InputEvent& operator= (InputEvent other) {
53 swap(*this, other);
54 return *this;
55 }
52 InputEvent& operator= (InputEvent other) {
53 swap(*this, other);
54 return *this;
55 }
5656
57 InputEvent(const InputEvent &other) {
58 memcpy(&event, &(other.event), sizeof(input_event));
59 }
57 InputEvent(const InputEvent &other) {
58 memcpy(&event, &(other.event), sizeof(input_event));
59 }
6060
61 };
61 };
6262
6363 }
6464 #endif //LIBEVDEVPLUS_INPUTEVENT_HPP
00 # libevdevPlus
11
2 [![pipeline status](https://gitlab.com/ReimuNotMoe/libevdevPlus/badges/master/pipeline.svg)](https://gitlab.com/ReimuNotMoe/libevdevPlus/pipelines)
3
4 ## Releases
5 - [Ubuntu 18.04](https://gitlab.com/ReimuNotMoe/libevdevPlus/-/jobs/artifacts/master/browse/build?job=package:ubuntu:18.04)
6 - [Ubuntu 19.04](https://gitlab.com/ReimuNotMoe/libevdevPlus/-/jobs/artifacts/master/browse/build?job=package:ubuntu:19.04)
7 - [Debian 9](https://gitlab.com/ReimuNotMoe/libevdevPlus/-/jobs/artifacts/master/browse/build?job=package:debian:9)
1111
1212 #include "evdevPlus.hpp"
1313
14 const std::unordered_map<std::string, int> evdevPlus::Table_FunctionKeys = {
14 const std::unordered_map<std::string, int> evdevPlus::Table_ModifierKeys = {
1515 {"ALT", KEY_LEFTALT}, {"ALT_L", KEY_LEFTALT}, {"ALT_R", KEY_RIGHTALT},
1616 {"SHIFT", KEY_LEFTSHIFT}, {"SHIFT_L", KEY_LEFTSHIFT}, {"SHIFT_R", KEY_RIGHTSHIFT},
1717 {"CTRL", KEY_LEFTCTRL}, {"CTRL_L", KEY_LEFTCTRL}, {"CTRL_R", KEY_RIGHTCTRL},
18 {"META", KEY_LEFTMETA}, {"META_L", KEY_LEFTMETA}, {"META_R", KEY_RIGHTMETA},
18 {"SUPER", KEY_LEFTMETA}, {"SUPER_L", KEY_LEFTMETA}, {"SUPER_R", KEY_RIGHTMETA},
19 {"META", KEY_LEFTMETA}, {"META_L", KEY_LEFTMETA}, {"META_R", KEY_RIGHTMETA}
20 };
21
22 const std::unordered_map<std::string, int> evdevPlus::Table_FunctionKeys = {
23 {"UP", KEY_UP}, {"DOWN", KEY_DOWN}, {"LEFT", KEY_LEFT}, {"RIGHT", KEY_RIGHT},
1924 {"TAB", KEY_TAB}, {"CAPSLOCK", KEY_CAPSLOCK}, {"NUMLOCK", KEY_NUMLOCK}, {"SCROLLLOCK", KEY_SCROLLLOCK}, {"ESC", KEY_ESC}, {"ENTER", KEY_ENTER}, {"BACKSPACE", KEY_BACKSPACE}, {"DELETE", KEY_DELETE},
2025 {"INSERT", KEY_INSERT}, {"HOME", KEY_HOME}, {"END", KEY_END}, {"PAGEUP", KEY_PAGEUP}, {"PAGEDOWN", KEY_PAGEDOWN}, {"SYSRQ", KEY_SYSRQ}, {"PAUSE", KEY_PAUSE},
2126 {"F1", KEY_F1}, {"F2", KEY_F2}, {"F3", KEY_F3}, {"F4", KEY_F4}, {"F5", KEY_F5}, {"F6", KEY_F6}, {"F7", KEY_F7}, {"F8", KEY_F8}, {"F9", KEY_F9}, {"F10", KEY_F10}, {"F11", KEY_F11}, {"F12", KEY_F12}
153158 {"KEY_CAMERA_RIGHT", KEY_CAMERA_RIGHT}, {"KEY_ATTENDANT_ON", KEY_ATTENDANT_ON},
154159 {"KEY_ATTENDANT_OFF", KEY_ATTENDANT_OFF}, {"KEY_ATTENDANT_TOGGLE", KEY_ATTENDANT_TOGGLE},
155160 {"KEY_LIGHTS_TOGGLE", KEY_LIGHTS_TOGGLE}, {"KEY_ALS_TOGGLE", KEY_ALS_TOGGLE},
156 {"KEY_ROTATE_LOCK_TOGGLE", KEY_ROTATE_LOCK_TOGGLE}, {"KEY_BUTTONCONFIG", KEY_BUTTONCONFIG},
161
157162 {"KEY_TASKMANAGER", KEY_TASKMANAGER}, {"KEY_JOURNAL", KEY_JOURNAL}, {"KEY_CONTROLPANEL", KEY_CONTROLPANEL},
158163 {"KEY_APPSELECT", KEY_APPSELECT}, {"KEY_SCREENSAVER", KEY_SCREENSAVER}, {"KEY_VOICECOMMAND", KEY_VOICECOMMAND},
159 {"KEY_ASSISTANT", KEY_ASSISTANT}, {"KEY_BRIGHTNESS_MIN", KEY_BRIGHTNESS_MIN},
164 {"KEY_BRIGHTNESS_MIN", KEY_BRIGHTNESS_MIN},
160165 {"KEY_BRIGHTNESS_MAX", KEY_BRIGHTNESS_MAX}, {"KEY_KBDINPUTASSIST_PREV", KEY_KBDINPUTASSIST_PREV},
161166 {"KEY_KBDINPUTASSIST_NEXT", KEY_KBDINPUTASSIST_NEXT},
162167 {"KEY_KBDINPUTASSIST_PREVGROUP", KEY_KBDINPUTASSIST_PREVGROUP},
169174 {"KEY_3D_MODE", KEY_3D_MODE}, {"KEY_NEXT_FAVORITE", KEY_NEXT_FAVORITE}, {"KEY_STOP_RECORD", KEY_STOP_RECORD},
170175 {"KEY_PAUSE_RECORD", KEY_PAUSE_RECORD}, {"KEY_VOD", KEY_VOD}, {"KEY_UNMUTE", KEY_UNMUTE},
171176 {"KEY_FASTREVERSE", KEY_FASTREVERSE}, {"KEY_SLOWREVERSE", KEY_SLOWREVERSE}, {"KEY_DATA", KEY_DATA},
172 {"KEY_ONSCREEN_KEYBOARD", KEY_ONSCREEN_KEYBOARD}, {"KEY_MIN_INTERESTING", KEY_MIN_INTERESTING},
177
178 {"KEY_MIN_INTERESTING", KEY_MIN_INTERESTING},
173179 {"BTN_MISC", BTN_MISC}, {"BTN_0", BTN_0}, {"BTN_1", BTN_1}, {"BTN_2", BTN_2}, {"BTN_3", BTN_3},
174180 {"BTN_4", BTN_4}, {"BTN_5", BTN_5}, {"BTN_6", BTN_6}, {"BTN_7", BTN_7}, {"BTN_8", BTN_8}, {"BTN_9", BTN_9},
175181 {"BTN_MOUSE", BTN_MOUSE}, {"BTN_LEFT", BTN_LEFT}, {"BTN_RIGHT", BTN_RIGHT}, {"BTN_MIDDLE", BTN_MIDDLE},
186192 {"BTN_TOOL_BRUSH", BTN_TOOL_BRUSH}, {"BTN_TOOL_PENCIL", BTN_TOOL_PENCIL},
187193 {"BTN_TOOL_AIRBRUSH", BTN_TOOL_AIRBRUSH}, {"BTN_TOOL_FINGER", BTN_TOOL_FINGER},
188194 {"BTN_TOOL_MOUSE", BTN_TOOL_MOUSE}, {"BTN_TOOL_LENS", BTN_TOOL_LENS}, {"BTN_TOOL_QUINTTAP", BTN_TOOL_QUINTTAP},
189 {"BTN_STYLUS3", BTN_STYLUS3}, {"BTN_TOUCH", BTN_TOUCH}, {"BTN_STYLUS", BTN_STYLUS},
195 {"BTN_TOUCH", BTN_TOUCH}, {"BTN_STYLUS", BTN_STYLUS},
190196 {"BTN_STYLUS2", BTN_STYLUS2}, {"BTN_TOOL_DOUBLETAP", BTN_TOOL_DOUBLETAP},
191197 {"BTN_TOOL_TRIPLETAP", BTN_TOOL_TRIPLETAP}, {"BTN_TOOL_QUADTAP", BTN_TOOL_QUADTAP}, {"BTN_WHEEL", BTN_WHEEL},
192198 {"BTN_GEAR_DOWN", BTN_GEAR_DOWN}, {"BTN_GEAR_UP", BTN_GEAR_UP}, {"BTN_DPAD_UP", BTN_DPAD_UP},
1717
1818 namespace evdevPlus {
1919
20 extern const std::unordered_map<std::string, int> Table_FunctionKeys;
21 extern const std::unordered_map<char, int> Table_LowerKeys;
22 extern const std::unordered_map<char, int> Table_UpperKeys;
23 extern const std::unordered_map<std::string, int> Table_KeyCodes;
20 extern const std::unordered_map<std::string, int> Table_FunctionKeys;
21 extern const std::unordered_map<std::string, int> Table_ModifierKeys;
22 extern const std::unordered_map<char, int> Table_LowerKeys;
23 extern const std::unordered_map<char, int> Table_UpperKeys;
24 extern const std::unordered_map<std::string, int> Table_KeyCodes;
2425
2526
26 class EventDeviceID {
27 public:
28 input_id inputId{};
27 class EventDeviceID {
28 public:
29 input_id inputId{};
2930
30 uint16_t &BusType = inputId.bustype;
31 uint16_t &Vendor = inputId.vendor;
32 uint16_t &Product = inputId.product;
33 uint16_t &Version = inputId.version;
31 uint16_t &BusType = inputId.bustype;
32 uint16_t &Vendor = inputId.vendor;
33 uint16_t &Product = inputId.product;
34 uint16_t &Version = inputId.version;
3435
35 EventDeviceID() = default;
36 EventDeviceID(uint16_t bus_type, uint16_t vid, uint16_t pid, uint16_t version) {
37 BusType = bus_type;
38 Vendor = vid;
39 Product = pid;
40 Version = version;
41 }
36 EventDeviceID() = default;
37 EventDeviceID(uint16_t bus_type, uint16_t vid, uint16_t pid, uint16_t version) {
38 BusType = bus_type;
39 Vendor = vid;
40 Product = pid;
41 Version = version;
42 }
4243
43 friend void swap(EventDeviceID &first, EventDeviceID &second) {
44 using std::swap;
44 friend void swap(EventDeviceID &first, EventDeviceID &second) {
45 using std::swap;
4546
46 swap(first.inputId, second.inputId);
47 }
47 swap(first.inputId, second.inputId);
48 }
4849
49 EventDeviceID(EventDeviceID &&other) noexcept : EventDeviceID() {
50 swap(*this, other);
51 }
50 EventDeviceID(EventDeviceID &&other) noexcept : EventDeviceID() {
51 swap(*this, other);
52 }
5253
53 EventDeviceID& operator= (EventDeviceID other) {
54 swap(*this, other);
55 return *this;
56 }
54 EventDeviceID& operator= (EventDeviceID other) {
55 swap(*this, other);
56 return *this;
57 }
5758
58 EventDeviceID(const EventDeviceID &other) {
59 memcpy(&inputId, &(other.inputId), sizeof(uinput_setup));
60 }
59 EventDeviceID(const EventDeviceID &other) {
60 memcpy(&inputId, &(other.inputId), sizeof(uinput_setup));
61 }
6162
62 };
63 };
6364
6465
65 class EventDevice {
66 public:
67 int FD = -1;
68 std::string Path;
66 class EventDevice {
67 public:
68 int FD = -1;
69 std::string Path;
6970
70 int DriverVersion = -1;
71 EventDeviceID DeviceID;
72 std::string DeviceName;
73 std::set<int> EventTypes;
71 int DriverVersion = -1;
72 EventDeviceID DeviceID;
73 std::string DeviceName;
74 std::set<int> EventTypes;
7475
75 EventDevice() = default;
76 EventDevice(const std::string &path, int open_flags = O_RDONLY) {
77 Open(path, open_flags);
78 }
79 EventDevice(int fd) {
80 Open(fd);
81 }
82 ~EventDevice() {
83 Close();
84 }
76 EventDevice() = default;
77 EventDevice(const std::string &path, int open_flags = O_RDONLY) {
78 Open(path, open_flags);
79 }
80 EventDevice(int fd) {
81 Open(fd);
82 }
83 ~EventDevice() {
84 Close();
85 }
8586
86 void Open(const std::string &path, int open_flags = O_RDONLY);
87 void Open(int fd);
88 void Close();
87 void Open(const std::string &path, int open_flags = O_RDONLY);
88 void Open(int fd);
89 void Close();
8990
90 void Init();
91 void Init();
9192
92 void Grab();
93 void Ungrab();
93 void Grab();
94 void Ungrab();
9495
95 InputEvent Read();
96 InputEvent Read();
9697
97 static bool IsValidDevice(int fd);
98 bool IsValidDevice();
98 static bool IsValidDevice(int fd);
99 bool IsValidDevice();
99100
100101
101 bool const operator== (const EventDevice &o) const {
102 return (Path == o.Path) && (FD == o.FD);
103 }
102 bool const operator== (const EventDevice &o) const {
103 return (Path == o.Path) && (FD == o.FD);
104 }
104105
105 };
106 };
106107 }
107108
108109
0 prefix=@CMAKE_INSTALL_PREFIX@
1 exec_prefix=${prefix}
2 includedir=${prefix}/include
3 libdir= ${prefix}/@CMAKE_INSTALL_LIBDIR@
4
5 Name: evdevPlus
6 Description: Easy-to-use event device library in C++
7 Version: 0.1.0
8 Cflags: -I${includedir}/evdevPlus
9 Libs: -L${libdir} -levdevPlus