Debian Codegraph @

src/shared.h

raw symbols SCIP
1 /* Adapted from test/shared.h from the libinput distribution */
2 /* tools/shared.h 1.23.0:
3 *
4 * Copyright © 2014 Red Hat, Inc.
5 * Modifications: Copyright © 2019 Bill Allombert <[email protected]>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
16 * Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
25 */
26
27 #ifndef _SHARED_H_
28 #define _SHARED_H_
29
30 #include <stdbool.h>
31
32 #include <libinput.h>
33 #include "config.h"
34
35 #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
36
37 enum configuration_options {
38 OPT_TAP_ENABLE = 256,
39 OPT_TAP_DISABLE,
40 OPT_TAP_MAP,
41 OPT_DRAG_ENABLE,
42 OPT_DRAG_DISABLE,
43 OPT_DRAG_LOCK_ENABLE,
44 OPT_DRAG_LOCK_DISABLE,
45 OPT_NATURAL_SCROLL_ENABLE,
46 OPT_NATURAL_SCROLL_DISABLE,
47 OPT_LEFT_HANDED_ENABLE,
48 OPT_LEFT_HANDED_DISABLE,
49 OPT_MIDDLEBUTTON_ENABLE,
50 OPT_MIDDLEBUTTON_DISABLE,
51 OPT_DWT_ENABLE,
52 OPT_DWT_DISABLE,
53 OPT_DWTP_ENABLE,
54 OPT_DWTP_DISABLE,
55 OPT_CLICK_METHOD,
56 OPT_CLICKFINGER_MAP,
57 OPT_SCROLL_METHOD,
58 OPT_SCROLL_BUTTON,
59 OPT_SCROLL_BUTTON_LOCK_ENABLE,
60 OPT_SCROLL_BUTTON_LOCK_DISABLE,
61 OPT_SPEED,
62 OPT_PROFILE,
63 OPT_DISABLE_SENDEVENTS,
64 OPT_APPLY_TO,
65 OPT_CUSTOM_POINTS,
66 OPT_CUSTOM_STEP,
67 OPT_CUSTOM_TYPE,
68 OPT_ROTATION_ANGLE
69 };
70
71 #define CONFIGURATION_OPTIONS \
72 { "disable-sendevents", required_argument, 0, OPT_DISABLE_SENDEVENTS }, \
73 { "enable-tap", no_argument, 0, OPT_TAP_ENABLE }, \
74 { "disable-tap", no_argument, 0, OPT_TAP_DISABLE }, \
75 { "enable-drag", no_argument, 0, OPT_DRAG_ENABLE }, \
76 { "disable-drag", no_argument, 0, OPT_DRAG_DISABLE }, \
77 { "enable-drag-lock", no_argument, 0, OPT_DRAG_LOCK_ENABLE }, \
78 { "disable-drag-lock", no_argument, 0, OPT_DRAG_LOCK_DISABLE }, \
79 { "enable-natural-scrolling", no_argument, 0, OPT_NATURAL_SCROLL_ENABLE }, \
80 { "disable-natural-scrolling", no_argument, 0, OPT_NATURAL_SCROLL_DISABLE }, \
81 { "enable-left-handed", no_argument, 0, OPT_LEFT_HANDED_ENABLE }, \
82 { "disable-left-handed", no_argument, 0, OPT_LEFT_HANDED_DISABLE }, \
83 { "enable-middlebutton", no_argument, 0, OPT_MIDDLEBUTTON_ENABLE }, \
84 { "disable-middlebutton", no_argument, 0, OPT_MIDDLEBUTTON_DISABLE }, \
85 { "enable-dwt", no_argument, 0, OPT_DWT_ENABLE }, \
86 { "disable-dwt", no_argument, 0, OPT_DWT_DISABLE }, \
87 { "enable-dwtp", no_argument, 0, OPT_DWTP_ENABLE }, \
88 { "disable-dwtp", no_argument, 0, OPT_DWTP_DISABLE }, \
89 { "enable-scroll-button-lock", no_argument, 0, OPT_SCROLL_BUTTON_LOCK_ENABLE }, \
90 { "disable-scroll-button-lock",no_argument, 0, OPT_SCROLL_BUTTON_LOCK_DISABLE }, \
91 { "set-click-method", required_argument, 0, OPT_CLICK_METHOD }, \
92 { "set-clickfinger-map", required_argument, 0, OPT_CLICKFINGER_MAP }, \
93 { "set-scroll-method", required_argument, 0, OPT_SCROLL_METHOD }, \
94 { "set-scroll-button", required_argument, 0, OPT_SCROLL_BUTTON }, \
95 { "set-profile", required_argument, 0, OPT_PROFILE }, \
96 { "set-tap-map", required_argument, 0, OPT_TAP_MAP }, \
97 { "set-speed", required_argument, 0, OPT_SPEED },\
98 { "apply-to", required_argument, 0, OPT_APPLY_TO },\
99 { "set-custom-points", required_argument, 0, OPT_CUSTOM_POINTS },\
100 { "set-custom-step", required_argument, 0, OPT_CUSTOM_STEP },\
101 { "set-custom-type", required_argument, 0, OPT_CUSTOM_TYPE },\
102 { "set-rotation-angle", required_argument, 0, OPT_ROTATION_ANGLE }
103
104 enum tools_backend {
105 BACKEND_NONE,
106 BACKEND_DEVICE,
107 BACKEND_UDEV
108 };
109
110 struct tools_options {
111 char match[256];
112
113 int tapping;
114 int drag;
115 int drag_lock;
116 int natural_scroll;
117 int left_handed;
118 int middlebutton;
119 enum libinput_config_click_method click_method;
120 #ifdef HAVE_LIBINPUT_1_26
121 enum libinput_config_clickfinger_button_map clickfinger_map;
122 #endif
123 enum libinput_config_scroll_method scroll_method;
124 enum libinput_config_tap_button_map tap_map;
125 int scroll_button;
126 int scroll_button_lock;
127 double speed;
128 int dwt;
129 int dwtp;
130 enum libinput_config_accel_profile profile;
131 char disable_pattern[64];
132 #ifdef HAVE_LIBINPUT_1_23
133 enum libinput_config_accel_type custom_type;
134 double custom_step;
135 size_t custom_npoints;
136 double *custom_points;
137 #endif
138 unsigned int angle;
139 };
140
141 void tools_init_options(struct tools_options *options);
142 int tools_parse_option(int option,
143 const char *optarg,
144 struct tools_options *options);
145 struct libinput* tools_open_backend(enum tools_backend which,
146 const char **seat_or_devices,
147 bool verbose,
148 bool *grab);
149 void tools_device_apply_config(struct libinput_device *device,
150 struct tools_options *options);
151 int tools_exec_command(const char *prefix, int argc, char **argv);
152
153 bool find_touchpad_device(char *path, size_t path_len);
154 bool is_touchpad_device(const char *devnode);
155
156 #endif