1+ /*
2+ libevdev-cpp - Minimal C++ libinput wrapper for InputActions
3+ Copyright (C) 2026 Marcin Woźniak
4+
5+ This program is free software: you can redistribute it and/or modify
6+ it under the terms of the GNU General Public License as published by
7+ the Free Software Foundation, either version 3 of the License, or
8+ (at your option) any later version.
9+
10+ This program is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ GNU General Public License for more details.
14+
15+ You should have received a copy of the GNU General Public License
16+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17+ */
18+
19+ #include " LibinputEvent.h"
20+ #include " LibinputGestureEvent.h"
21+ #include " LibinputKeyboardEvent.h"
22+ #include " LibinputPointerEvent.h"
23+
24+ namespace InputActions
25+ {
26+
27+ LibinputEvent::LibinputEvent (libinput_event *event)
28+ : m_event(event)
29+ {
30+ }
31+
32+ LibinputEvent::~LibinputEvent ()
33+ {
34+ libinput_event_destroy (m_event);
35+ }
36+
37+ libinput_event_type LibinputEvent::type () const
38+ {
39+ return libinput_event_get_type (m_event);
40+ }
41+
42+ std::optional<LibinputGestureEvent> LibinputEvent::gestureEvent () const
43+ {
44+ auto *event = libinput_event_get_gesture_event (m_event);
45+ if (!event) {
46+ return {};
47+ }
48+
49+ return LibinputGestureEvent (event);
50+ }
51+
52+ std::optional<LibinputKeyboardEvent> LibinputEvent::keyboardEvent () const
53+ {
54+ auto *event = libinput_event_get_keyboard_event (m_event);
55+ if (!event) {
56+ return {};
57+ }
58+
59+ return LibinputKeyboardEvent (event);
60+ }
61+
62+ std::optional<LibinputPointerEvent> LibinputEvent::pointerEvent () const
63+ {
64+ auto *event = libinput_event_get_pointer_event (m_event);
65+ if (!event) {
66+ return {};
67+ }
68+
69+ return LibinputPointerEvent (event);
70+ }
71+
72+ }
0 commit comments