summaryrefslogtreecommitdiff
path: root/tools/shared.h
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-06-19 18:38:33 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-06-26 18:43:59 +1000
commitd1b7b6267c0689c44dab2e73a0e5ac7da611e377 (patch)
tree46ece2ef55adcef2dc3616e9cce84e2d00c6e079 /tools/shared.h
parentbe7da7f7daa3b551bb9418b62bc5490ddcfa21e7 (diff)
downloadlibinput-d1b7b6267c0689c44dab2e73a0e5ac7da611e377.tar.gz
tools: split the configuration option parsing out
We had one shared parsing function for all config options so tools parse options that don't actually make sense (e.g. --quiet or --show-keycodes for libinput-list-devices). This patch splits the actual libinput device configuration out and reshuffles everything to make use of that. One large patch, because splitting this up is more confusing than dumping it all. This means the actual option parsing is partially duplicated between debug-gui and debug-events but hey, not everything in life is perfect. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools/shared.h')
-rw-r--r--tools/shared.h73
1 files changed, 53 insertions, 20 deletions
diff --git a/tools/shared.h b/tools/shared.h
index 0a39484e..ceaa08a9 100644
--- a/tools/shared.h
+++ b/tools/shared.h
@@ -28,20 +28,57 @@
#include <libinput.h>
+enum configuration_options {
+ OPT_TAP_ENABLE = 256,
+ OPT_TAP_DISABLE,
+ OPT_TAP_MAP,
+ OPT_DRAG_ENABLE,
+ OPT_DRAG_DISABLE,
+ OPT_DRAG_LOCK_ENABLE,
+ OPT_DRAG_LOCK_DISABLE,
+ OPT_NATURAL_SCROLL_ENABLE,
+ OPT_NATURAL_SCROLL_DISABLE,
+ OPT_LEFT_HANDED_ENABLE,
+ OPT_LEFT_HANDED_DISABLE,
+ OPT_MIDDLEBUTTON_ENABLE,
+ OPT_MIDDLEBUTTON_DISABLE,
+ OPT_DWT_ENABLE,
+ OPT_DWT_DISABLE,
+ OPT_CLICK_METHOD,
+ OPT_SCROLL_METHOD,
+ OPT_SCROLL_BUTTON,
+ OPT_SPEED,
+ OPT_PROFILE,
+};
+
+#define CONFIGURATION_OPTIONS \
+ { "enable-tap", no_argument, 0, OPT_TAP_ENABLE }, \
+ { "disable-tap", no_argument, 0, OPT_TAP_DISABLE }, \
+ { "enable-drag", no_argument, 0, OPT_DRAG_ENABLE }, \
+ { "disable-drag", no_argument, 0, OPT_DRAG_DISABLE }, \
+ { "enable-drag-lock", no_argument, 0, OPT_DRAG_LOCK_ENABLE }, \
+ { "disable-drag-lock", no_argument, 0, OPT_DRAG_LOCK_DISABLE }, \
+ { "enable-natural-scrolling", no_argument, 0, OPT_NATURAL_SCROLL_ENABLE }, \
+ { "disable-natural-scrolling", no_argument, 0, OPT_NATURAL_SCROLL_DISABLE }, \
+ { "enable-left-handed", no_argument, 0, OPT_LEFT_HANDED_ENABLE }, \
+ { "disable-left-handed", no_argument, 0, OPT_LEFT_HANDED_DISABLE }, \
+ { "enable-middlebutton", no_argument, 0, OPT_MIDDLEBUTTON_ENABLE }, \
+ { "disable-middlebutton", no_argument, 0, OPT_MIDDLEBUTTON_DISABLE }, \
+ { "enable-dwt", no_argument, 0, OPT_DWT_ENABLE }, \
+ { "disable-dwt", no_argument, 0, OPT_DWT_DISABLE }, \
+ { "set-click-method", required_argument, 0, OPT_CLICK_METHOD }, \
+ { "set-scroll-method", required_argument, 0, OPT_SCROLL_METHOD }, \
+ { "set-scroll-button", required_argument, 0, OPT_SCROLL_BUTTON }, \
+ { "set-profile", required_argument, 0, OPT_PROFILE }, \
+ { "set-tap-map", required_argument, 0, OPT_TAP_MAP }, \
+ { "set-speed", required_argument, 0, OPT_SPEED }
+
enum tools_backend {
BACKEND_DEVICE,
BACKEND_UDEV
};
struct tools_options {
- bool verbose;
- bool quiet;
- enum tools_backend backend;
- const char *device; /* if backend is BACKEND_DEVICE */
- const char *seat; /* if backend is BACKEND_UDEV */
- int grab; /* EVIOCGRAB */
- bool show_keycodes; /* show keycodes */
-
int tapping;
int drag;
int drag_lock;
@@ -57,20 +94,16 @@ struct tools_options {
enum libinput_config_accel_profile profile;
};
-struct tools_context {
- struct tools_options options;
- void *user_data;
-};
-
-void tools_init_context(struct tools_context *context);
-int tools_parse_args(const char *command,
- int argc,
- char **argv,
- struct tools_context *context);
-struct libinput* tools_open_backend(struct tools_context *context);
+void tools_init_options(struct tools_options *options);
+int tools_parse_option(int option,
+ const char *optarg,
+ struct tools_options *options);
+struct libinput* tools_open_backend(enum tools_backend which,
+ const char *seat_or_device,
+ bool verbose,
+ bool grab);
void tools_device_apply_config(struct libinput_device *device,
struct tools_options *options);
-void tools_usage(const char *command);
int tools_exec_command(const char *prefix, int argc, char **argv);
bool find_touchpad_device(char *path, size_t path_len);