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