1 #ifndef BACKEND_LIBINPUT_H
2 #define BACKEND_LIBINPUT_H
3 
4 #include <libinput.h>
5 #include <wayland-server-core.h>
6 #include <wlr/backend/interface.h>
7 #include <wlr/backend/libinput.h>
8 #include <wlr/interfaces/wlr_input_device.h>
9 #include <wlr/types/wlr_input_device.h>
10 #include <wlr/types/wlr_list.h>
11 
12 struct wlr_libinput_backend {
13 	struct wlr_backend backend;
14 
15 	struct wlr_session *session;
16 	struct wl_display *display;
17 
18 	struct libinput *libinput_context;
19 	struct wl_event_source *input_event;
20 
21 	struct wl_listener display_destroy;
22 	struct wl_listener session_destroy;
23 	struct wl_listener session_signal;
24 
25 	struct wlr_list wlr_device_lists; // list of struct wl_list
26 };
27 
28 struct wlr_libinput_input_device {
29 	struct wlr_input_device wlr_input_device;
30 
31 	struct libinput_device *handle;
32 };
33 
34 uint32_t usec_to_msec(uint64_t usec);
35 
36 void handle_libinput_event(struct wlr_libinput_backend *state,
37 		struct libinput_event *event);
38 
39 struct wlr_input_device *get_appropriate_device(
40 		enum wlr_input_device_type desired_type,
41 		struct libinput_device *device);
42 
43 struct wlr_keyboard *create_libinput_keyboard(
44 		struct libinput_device *device);
45 void handle_keyboard_key(struct libinput_event *event,
46 		struct libinput_device *device);
47 
48 struct wlr_pointer *create_libinput_pointer(
49 		struct libinput_device *device);
50 void handle_pointer_motion(struct libinput_event *event,
51 		struct libinput_device *device);
52 void handle_pointer_motion_abs(struct libinput_event *event,
53 		struct libinput_device *device);
54 void handle_pointer_button(struct libinput_event *event,
55 		struct libinput_device *device);
56 void handle_pointer_axis(struct libinput_event *event,
57 		struct libinput_device *device);
58 void handle_pointer_swipe_begin(struct libinput_event *event,
59 		struct libinput_device *device);
60 void handle_pointer_swipe_update(struct libinput_event *event,
61 		struct libinput_device *device);
62 void handle_pointer_swipe_end(struct libinput_event *event,
63 		struct libinput_device *device);
64 void handle_pointer_pinch_begin(struct libinput_event *event,
65 		struct libinput_device *device);
66 void handle_pointer_pinch_update(struct libinput_event *event,
67 		struct libinput_device *device);
68 void handle_pointer_pinch_end(struct libinput_event *event,
69 		struct libinput_device *device);
70 
71 struct wlr_switch *create_libinput_switch(
72 		struct libinput_device *device);
73 void handle_switch_toggle(struct libinput_event *event,
74 		struct libinput_device *device);
75 
76 struct wlr_touch *create_libinput_touch(
77 		struct libinput_device *device);
78 void handle_touch_down(struct libinput_event *event,
79 		struct libinput_device *device);
80 void handle_touch_up(struct libinput_event *event,
81 		struct libinput_device *device);
82 void handle_touch_motion(struct libinput_event *event,
83 		struct libinput_device *device);
84 void handle_touch_cancel(struct libinput_event *event,
85 		struct libinput_device *device);
86 
87 struct wlr_tablet *create_libinput_tablet(
88 		struct libinput_device *device);
89 void handle_tablet_tool_axis(struct libinput_event *event,
90 		struct libinput_device *device);
91 void handle_tablet_tool_proximity(struct libinput_event *event,
92 		struct libinput_device *device);
93 void handle_tablet_tool_tip(struct libinput_event *event,
94 		struct libinput_device *device);
95 void handle_tablet_tool_button(struct libinput_event *event,
96 		struct libinput_device *device);
97 
98 struct wlr_tablet_pad *create_libinput_tablet_pad(
99 		struct libinput_device *device);
100 void handle_tablet_pad_button(struct libinput_event *event,
101 		struct libinput_device *device);
102 void handle_tablet_pad_ring(struct libinput_event *event,
103 		struct libinput_device *device);
104 void handle_tablet_pad_strip(struct libinput_event *event,
105 		struct libinput_device *device);
106 
107 #endif
108