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