aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/input.c55
-rw-r--r--sway/commands/input/accel_profile.c27
-rw-r--r--sway/commands/input/click_method.c30
-rw-r--r--sway/commands/input/drag_lock.c26
-rw-r--r--sway/commands/input/dwt.c26
-rw-r--r--sway/commands/input/events.c30
-rw-r--r--sway/commands/input/left_handed.c26
-rw-r--r--sway/commands/input/middle_emulation.c26
-rw-r--r--sway/commands/input/natural_scroll.c26
-rw-r--r--sway/commands/input/pointer_accel.c24
-rw-r--r--sway/commands/input/scroll_method.c30
-rw-r--r--sway/commands/input/tap.c29
12 files changed, 355 insertions, 0 deletions
diff --git a/sway/commands/input.c b/sway/commands/input.c
new file mode 100644
index 00000000..5ca9c2e6
--- /dev/null
+++ b/sway/commands/input.c
@@ -0,0 +1,55 @@
+#include <string.h>
+#include <strings.h>
+#include "sway/commands.h"
+#include "sway/input/input-manager.h"
+#include "log.h"
+
+struct cmd_results *cmd_input(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "input", EXPECTED_AT_LEAST, 2))) {
+ return error;
+ }
+
+ if (config->reading && strcmp("{", argv[1]) == 0) {
+ current_input_config = new_input_config(argv[0]);
+ sway_log(L_DEBUG, "entering input block: %s", current_input_config->identifier);
+ return cmd_results_new(CMD_BLOCK_INPUT, NULL, NULL);
+ }
+
+ if (argc > 2) {
+ int argc_new = argc-2;
+ char **argv_new = argv+2;
+
+ struct cmd_results *res;
+ current_input_config = new_input_config(argv[0]);
+ if (strcasecmp("accel_profile", argv[1]) == 0) {
+ res = input_cmd_accel_profile(argc_new, argv_new);
+ } else if (strcasecmp("click_method", argv[1]) == 0) {
+ res = input_cmd_click_method(argc_new, argv_new);
+ } else if (strcasecmp("drag_lock", argv[1]) == 0) {
+ res = input_cmd_drag_lock(argc_new, argv_new);
+ } else if (strcasecmp("dwt", argv[1]) == 0) {
+ res = input_cmd_dwt(argc_new, argv_new);
+ } else if (strcasecmp("events", argv[1]) == 0) {
+ res = input_cmd_events(argc_new, argv_new);
+ } else if (strcasecmp("left_handed", argv[1]) == 0) {
+ res = input_cmd_left_handed(argc_new, argv_new);
+ } else if (strcasecmp("middle_emulation", argv[1]) == 0) {
+ res = input_cmd_middle_emulation(argc_new, argv_new);
+ } else if (strcasecmp("natural_scroll", argv[1]) == 0) {
+ res = input_cmd_natural_scroll(argc_new, argv_new);
+ } else if (strcasecmp("pointer_accel", argv[1]) == 0) {
+ res = input_cmd_pointer_accel(argc_new, argv_new);
+ } else if (strcasecmp("scroll_method", argv[1]) == 0) {
+ res = input_cmd_scroll_method(argc_new, argv_new);
+ } else if (strcasecmp("tap", argv[1]) == 0) {
+ res = input_cmd_tap(argc_new, argv_new);
+ } else {
+ res = cmd_results_new(CMD_INVALID, "input <device>", "Unknown command %s", argv[1]);
+ }
+ current_input_config = NULL;
+ return res;
+ }
+
+ return cmd_results_new(CMD_BLOCK_INPUT, NULL, NULL);
+}
diff --git a/sway/commands/input/accel_profile.c b/sway/commands/input/accel_profile.c
new file mode 100644
index 00000000..13ded431
--- /dev/null
+++ b/sway/commands/input/accel_profile.c
@@ -0,0 +1,27 @@
+#include <string.h>
+#include <strings.h>
+#include "sway/commands.h"
+#include "sway/input/input-manager.h"
+
+struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "accel_profile", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+ if (!current_input_config) {
+ return cmd_results_new(CMD_FAILURE, "accel_profile", "No input device defined.");
+ }
+ struct input_config *new_config = new_input_config(current_input_config->identifier);
+
+ if (strcasecmp(argv[0], "adaptive") == 0) {
+ new_config->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
+ } else if (strcasecmp(argv[0], "flat") == 0) {
+ new_config->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
+ } else {
+ return cmd_results_new(CMD_INVALID, "accel_profile",
+ "Expected 'accel_profile <adaptive|flat>'");
+ }
+
+ input_cmd_apply(new_config);
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
diff --git a/sway/commands/input/click_method.c b/sway/commands/input/click_method.c
new file mode 100644
index 00000000..40f075ce
--- /dev/null
+++ b/sway/commands/input/click_method.c
@@ -0,0 +1,30 @@
+#include <string.h>
+#include <strings.h>
+#include "sway/commands.h"
+#include "sway/input/input-manager.h"
+#include "log.h"
+
+struct cmd_results *input_cmd_click_method(int argc, char **argv) {
+ sway_log(L_DEBUG, "click_method for device: %d %s", current_input_config==NULL, current_input_config->identifier);
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "click_method", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+ if (!current_input_config) {
+ return cmd_results_new(CMD_FAILURE, "click_method", "No input device defined.");
+ }
+ struct input_config *new_config = new_input_config(current_input_config->identifier);
+
+ if (strcasecmp(argv[0], "none") == 0) {
+ new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_NONE;
+ } else if (strcasecmp(argv[0], "button_areas") == 0) {
+ new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
+ } else if (strcasecmp(argv[0], "clickfinger") == 0) {
+ new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
+ } else {
+ return cmd_results_new(CMD_INVALID, "click_method", "Expected 'click_method <none|button_areas|clickfinger'");
+ }
+
+ input_cmd_apply(new_config);
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
diff --git a/sway/commands/input/drag_lock.c b/sway/commands/input/drag_lock.c
new file mode 100644
index 00000000..11e7fbea
--- /dev/null
+++ b/sway/commands/input/drag_lock.c
@@ -0,0 +1,26 @@
+#include <string.h>
+#include <strings.h>
+#include "sway/commands.h"
+#include "sway/input/input-manager.h"
+
+struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "drag_lock", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+ if (!current_input_config) {
+ return cmd_results_new(CMD_FAILURE, "drag_lock", "No input device defined.");
+ }
+ struct input_config *new_config = new_input_config(current_input_config->identifier);
+
+ if (strcasecmp(argv[0], "enabled") == 0) {
+ new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_ENABLED;
+ } else if (strcasecmp(argv[0], "disabled") == 0) {
+ new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED;
+ } else {
+ return cmd_results_new(CMD_INVALID, "drag_lock", "Expected 'drag_lock <enabled|disabled>'");
+ }
+
+ input_cmd_apply(new_config);
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
diff --git a/sway/commands/input/dwt.c b/sway/commands/input/dwt.c
new file mode 100644
index 00000000..f3cbf252
--- /dev/null
+++ b/sway/commands/input/dwt.c
@@ -0,0 +1,26 @@
+#include <string.h>
+#include <strings.h>
+#include "sway/commands.h"
+#include "sway/input/input-manager.h"
+
+struct cmd_results *input_cmd_dwt(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "dwt", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+ if (!current_input_config) {
+ return cmd_results_new(CMD_FAILURE, "dwt", "No input device defined.");
+ }
+ struct input_config *new_config = new_input_config(current_input_config->identifier);
+
+ if (strcasecmp(argv[0], "enabled") == 0) {
+ new_config->dwt = LIBINPUT_CONFIG_DWT_ENABLED;
+ } else if (strcasecmp(argv[0], "disabled") == 0) {
+ new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED;
+ } else {
+ return cmd_results_new(CMD_INVALID, "dwt", "Expected 'dwt <enabled|disabled>'");
+ }
+
+ input_cmd_apply(new_config);
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
diff --git a/sway/commands/input/events.c b/sway/commands/input/events.c
new file mode 100644
index 00000000..4b2fdff5
--- /dev/null
+++ b/sway/commands/input/events.c
@@ -0,0 +1,30 @@
+#include <string.h>
+#include <strings.h>
+#include "sway/commands.h"
+#include "sway/input/input-manager.h"
+#include "log.h"
+
+struct cmd_results *input_cmd_events(int argc, char **argv) {
+ sway_log(L_DEBUG, "events for device: %s", current_input_config->identifier);
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "events", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+ if (!current_input_config) {
+ return cmd_results_new(CMD_FAILURE, "events", "No input device defined.");
+ }
+ struct input_config *new_config = new_input_config(current_input_config->identifier);
+
+ if (strcasecmp(argv[0], "enabled") == 0) {
+ new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
+ } else if (strcasecmp(argv[0], "disabled") == 0) {
+ new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
+ } else if (strcasecmp(argv[0], "disabled_on_external_mouse") == 0) {
+ new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE;
+ } else {
+ return cmd_results_new(CMD_INVALID, "events", "Expected 'events <enabled|disabled|disabled_on_external_mouse>'");
+ }
+
+ input_cmd_apply(new_config);
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
diff --git a/sway/commands/input/left_handed.c b/sway/commands/input/left_handed.c
new file mode 100644
index 00000000..715df2a1
--- /dev/null
+++ b/sway/commands/input/left_handed.c
@@ -0,0 +1,26 @@
+#include <string.h>
+#include <strings.h>
+#include "sway/commands.h"
+#include "sway/input/input-manager.h"
+
+struct cmd_results *input_cmd_left_handed(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "left_handed", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+ if (!current_input_config) {
+ return cmd_results_new(CMD_FAILURE, "left_handed", "No input device defined.");
+ }
+ struct input_config *new_config = new_input_config(current_input_config->identifier);
+
+ if (strcasecmp(argv[0], "enabled") == 0) {
+ new_config->left_handed = 1;
+ } else if (strcasecmp(argv[0], "disabled") == 0) {
+ new_config->left_handed = 0;
+ } else {
+ return cmd_results_new(CMD_INVALID, "left_handed", "Expected 'left_handed <enabled|disabled>'");
+ }
+
+ input_cmd_apply(new_config);
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
diff --git a/sway/commands/input/middle_emulation.c b/sway/commands/input/middle_emulation.c
new file mode 100644
index 00000000..d31ce950
--- /dev/null
+++ b/sway/commands/input/middle_emulation.c
@@ -0,0 +1,26 @@
+#include <string.h>
+#include <strings.h>
+#include "sway/commands.h"
+#include "sway/input/input-manager.h"
+
+struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "middle_emulation", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+ if (!current_input_config) {
+ return cmd_results_new(CMD_FAILURE, "middle_emulation", "No input device defined.");
+ }
+ struct input_config *new_config = new_input_config(current_input_config->identifier);
+
+ if (strcasecmp(argv[0], "enabled") == 0) {
+ new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED;
+ } else if (strcasecmp(argv[0], "disabled") == 0) {
+ new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
+ } else {
+ return cmd_results_new(CMD_INVALID, "middle_emulation", "Expected 'middle_emulation <enabled|disabled>'");
+ }
+
+ input_cmd_apply(new_config);
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
diff --git a/sway/commands/input/natural_scroll.c b/sway/commands/input/natural_scroll.c
new file mode 100644
index 00000000..9d1dc506
--- /dev/null
+++ b/sway/commands/input/natural_scroll.c
@@ -0,0 +1,26 @@
+#include <string.h>
+#include <strings.h>
+#include "sway/commands.h"
+#include "sway/input/input-manager.h"
+
+struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "natural_scroll", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+ if (!current_input_config) {
+ return cmd_results_new(CMD_FAILURE, "natural_scoll", "No input device defined.");
+ }
+ struct input_config *new_config = new_input_config(current_input_config->identifier);
+
+ if (strcasecmp(argv[0], "enabled") == 0) {
+ new_config->natural_scroll = 1;
+ } else if (strcasecmp(argv[0], "disabled") == 0) {
+ new_config->natural_scroll = 0;
+ } else {
+ return cmd_results_new(CMD_INVALID, "natural_scroll", "Expected 'natural_scroll <enabled|disabled>'");
+ }
+
+ input_cmd_apply(new_config);
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
diff --git a/sway/commands/input/pointer_accel.c b/sway/commands/input/pointer_accel.c
new file mode 100644
index 00000000..87fb5cff
--- /dev/null
+++ b/sway/commands/input/pointer_accel.c
@@ -0,0 +1,24 @@
+#include <stdlib.h>
+#include <string.h>
+#include "sway/commands.h"
+#include "sway/input/input-manager.h"
+
+struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "pointer_accel", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+ if (!current_input_config) {
+ return cmd_results_new(CMD_FAILURE, "pointer_accel", "No input device defined.");
+ }
+ struct input_config *new_config = new_input_config(current_input_config->identifier);
+
+ float pointer_accel = atof(argv[0]);
+ if (pointer_accel < -1 || pointer_accel > 1) {
+ return cmd_results_new(CMD_INVALID, "pointer_accel", "Input out of range [-1, 1]");
+ }
+ new_config->pointer_accel = pointer_accel;
+
+ input_cmd_apply(new_config);
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
diff --git a/sway/commands/input/scroll_method.c b/sway/commands/input/scroll_method.c
new file mode 100644
index 00000000..98873938
--- /dev/null
+++ b/sway/commands/input/scroll_method.c
@@ -0,0 +1,30 @@
+#include <string.h>
+#include <strings.h>
+#include "sway/commands.h"
+#include "sway/input/input-manager.h"
+
+struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "scroll_method", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+ if (!current_input_config) {
+ return cmd_results_new(CMD_FAILURE, "scroll_method", "No input device defined.");
+ }
+ struct input_config *new_config = new_input_config(current_input_config->identifier);
+
+ if (strcasecmp(argv[0], "none") == 0) {
+ new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
+ } else if (strcasecmp(argv[0], "two_finger") == 0) {
+ new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_2FG;
+ } else if (strcasecmp(argv[0], "edge") == 0) {
+ new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_EDGE;
+ } else if (strcasecmp(argv[0], "on_button_down") == 0) {
+ new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
+ } else {
+ return cmd_results_new(CMD_INVALID, "scroll_method", "Expected 'scroll_method <none|two_finger|edge|on_button_down>'");
+ }
+
+ input_cmd_apply(new_config);
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
diff --git a/sway/commands/input/tap.c b/sway/commands/input/tap.c
new file mode 100644
index 00000000..1109466f
--- /dev/null
+++ b/sway/commands/input/tap.c
@@ -0,0 +1,29 @@
+#include <string.h>
+#include <strings.h>
+#include "sway/commands.h"
+#include "sway/input/input-manager.h"
+#include "log.h"
+
+struct cmd_results *input_cmd_tap(int argc, char **argv) {
+ sway_log(L_DEBUG, "tap for device: %s", current_input_config->identifier);
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "tap", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+ if (!current_input_config) {
+ return cmd_results_new(CMD_FAILURE, "tap", "No input device defined.");
+ }
+ struct input_config *new_config = new_input_config(current_input_config->identifier);
+
+ if (strcasecmp(argv[0], "enabled") == 0) {
+ new_config->tap = LIBINPUT_CONFIG_TAP_ENABLED;
+ } else if (strcasecmp(argv[0], "disabled") == 0) {
+ new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED;
+ } else {
+ return cmd_results_new(CMD_INVALID, "tap", "Expected 'tap <enabled|disabled>'");
+ }
+
+ sway_log(L_DEBUG, "apply-tap for device: %s", current_input_config->identifier);
+ input_cmd_apply(new_config);
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}