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