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_CLICK_METHOD, 52 OPT_SCROLL_METHOD, 53 OPT_SCROLL_BUTTON, 54 OPT_SCROLL_BUTTON_LOCK_ENABLE, 55 OPT_SCROLL_BUTTON_LOCK_DISABLE, 56 OPT_SPEED, 57 OPT_PROFILE, 58 OPT_DISABLE_SENDEVENTS, 59 OPT_APPLY_TO, 60 }; 61 62 #define CONFIGURATION_OPTIONS \ 63 { "disable-sendevents", required_argument, 0, OPT_DISABLE_SENDEVENTS }, \ 64 { "enable-tap", no_argument, 0, OPT_TAP_ENABLE }, \ 65 { "disable-tap", no_argument, 0, OPT_TAP_DISABLE }, \ 66 { "enable-drag", no_argument, 0, OPT_DRAG_ENABLE }, \ 67 { "disable-drag", no_argument, 0, OPT_DRAG_DISABLE }, \ 68 { "enable-drag-lock", no_argument, 0, OPT_DRAG_LOCK_ENABLE }, \ 69 { "disable-drag-lock", no_argument, 0, OPT_DRAG_LOCK_DISABLE }, \ 70 { "enable-natural-scrolling", no_argument, 0, OPT_NATURAL_SCROLL_ENABLE }, \ 71 { "disable-natural-scrolling", no_argument, 0, OPT_NATURAL_SCROLL_DISABLE }, \ 72 { "enable-left-handed", no_argument, 0, OPT_LEFT_HANDED_ENABLE }, \ 73 { "disable-left-handed", no_argument, 0, OPT_LEFT_HANDED_DISABLE }, \ 74 { "enable-middlebutton", no_argument, 0, OPT_MIDDLEBUTTON_ENABLE }, \ 75 { "disable-middlebutton", no_argument, 0, OPT_MIDDLEBUTTON_DISABLE }, \ 76 { "enable-dwt", no_argument, 0, OPT_DWT_ENABLE }, \ 77 { "disable-dwt", no_argument, 0, OPT_DWT_DISABLE }, \ 78 { "enable-scroll-button-lock", no_argument, 0, OPT_SCROLL_BUTTON_LOCK_ENABLE }, \ 79 { "disable-scroll-button-lock",no_argument, 0, OPT_SCROLL_BUTTON_LOCK_DISABLE }, \ 80 { "set-click-method", required_argument, 0, OPT_CLICK_METHOD }, \ 81 { "set-scroll-method", required_argument, 0, OPT_SCROLL_METHOD }, \ 82 { "set-scroll-button", required_argument, 0, OPT_SCROLL_BUTTON }, \ 83 { "set-profile", required_argument, 0, OPT_PROFILE }, \ 84 { "set-tap-map", required_argument, 0, OPT_TAP_MAP }, \ 85 { "set-speed", required_argument, 0, OPT_SPEED },\ 86 { "apply-to", required_argument, 0, OPT_APPLY_TO } 87 88 enum tools_backend { 89 BACKEND_NONE, 90 BACKEND_DEVICE, 91 BACKEND_UDEV 92 }; 93 94 struct tools_options { 95 char match[256]; 96 97 int tapping; 98 int drag; 99 int drag_lock; 100 int natural_scroll; 101 int left_handed; 102 int middlebutton; 103 enum libinput_config_click_method click_method; 104 enum libinput_config_scroll_method scroll_method; 105 enum libinput_config_tap_button_map tap_map; 106 int scroll_button; 107 int scroll_button_lock; 108 double speed; 109 int dwt; 110 enum libinput_config_accel_profile profile; 111 char disable_pattern[64]; 112 }; 113 114 void tools_init_options(struct tools_options *options); 115 int tools_parse_option(int option, 116 const char *optarg, 117 struct tools_options *options); 118 struct libinput* tools_open_backend(enum tools_backend which, 119 const char **seat_or_devices, 120 bool verbose, 121 bool *grab); 122 void tools_device_apply_config(struct libinput_device *device, 123 struct tools_options *options); 124 int tools_exec_command(const char *prefix, int argc, char **argv); 125 126 bool find_touchpad_device(char *path, size_t path_len); 127 bool is_touchpad_device(const char *devnode); 128 129 void 130 tools_list_device_quirks(struct quirks_context *ctx, 131 struct udev_device *device, 132 void (*callback)(void *userdata, const char *str), 133 void *userdata); 134 135 void 136 tools_dispatch(struct libinput *libinput); 137 #endif 138