aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/input
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2017-12-12 09:02:30 -0500
committerLibravatar Tony Crisci <tony@dubstepdish.com>2017-12-12 09:03:58 -0500
commit538903bc5ace56c1dab0f5287fb4d0bab78a0165 (patch)
treed45d08f64e98a76c730145cf3ea75dd199d9f6c8 /sway/commands/input
parentsway input device (diff)
downloadsway-538903bc5ace56c1dab0f5287fb4d0bab78a0165.tar.gz
sway-538903bc5ace56c1dab0f5287fb4d0bab78a0165.tar.zst
sway-538903bc5ace56c1dab0f5287fb4d0bab78a0165.zip
config cleanup
Diffstat (limited to 'sway/commands/input')
-rw-r--r--sway/commands/input/accel_profile.c6
-rw-r--r--sway/commands/input/click_method.c12
-rw-r--r--sway/commands/input/drag_lock.c9
-rw-r--r--sway/commands/input/dwt.c6
-rw-r--r--sway/commands/input/events.c15
-rw-r--r--sway/commands/input/left_handed.c9
-rw-r--r--sway/commands/input/middle_emulation.c12
-rw-r--r--sway/commands/input/natural_scroll.c9
-rw-r--r--sway/commands/input/pointer_accel.c9
-rw-r--r--sway/commands/input/scroll_method.c9
-rw-r--r--sway/commands/input/tap.c9
11 files changed, 70 insertions, 35 deletions
diff --git a/sway/commands/input/accel_profile.c b/sway/commands/input/accel_profile.c
index 13ded431..9b5fb7a2 100644
--- a/sway/commands/input/accel_profile.c
+++ b/sway/commands/input/accel_profile.c
@@ -9,9 +9,11 @@ struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
9 return error; 9 return error;
10 } 10 }
11 if (!current_input_config) { 11 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "accel_profile", "No input device defined."); 12 return cmd_results_new(CMD_FAILURE, "accel_profile",
13 "No input device defined.");
13 } 14 }
14 struct input_config *new_config = new_input_config(current_input_config->identifier); 15 struct input_config *new_config =
16 new_input_config(current_input_config->identifier);
15 17
16 if (strcasecmp(argv[0], "adaptive") == 0) { 18 if (strcasecmp(argv[0], "adaptive") == 0) {
17 new_config->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE; 19 new_config->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
diff --git a/sway/commands/input/click_method.c b/sway/commands/input/click_method.c
index 40f075ce..a0e3bddf 100644
--- a/sway/commands/input/click_method.c
+++ b/sway/commands/input/click_method.c
@@ -5,15 +5,18 @@
5#include "log.h" 5#include "log.h"
6 6
7struct cmd_results *input_cmd_click_method(int argc, char **argv) { 7struct cmd_results *input_cmd_click_method(int argc, char **argv) {
8 sway_log(L_DEBUG, "click_method for device: %d %s", current_input_config==NULL, current_input_config->identifier); 8 sway_log(L_DEBUG, "click_method for device: %d %s",
9 current_input_config==NULL, current_input_config->identifier);
9 struct cmd_results *error = NULL; 10 struct cmd_results *error = NULL;
10 if ((error = checkarg(argc, "click_method", EXPECTED_AT_LEAST, 1))) { 11 if ((error = checkarg(argc, "click_method", EXPECTED_AT_LEAST, 1))) {
11 return error; 12 return error;
12 } 13 }
13 if (!current_input_config) { 14 if (!current_input_config) {
14 return cmd_results_new(CMD_FAILURE, "click_method", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "click_method",
16 "No input device defined.");
15 } 17 }
16 struct input_config *new_config = new_input_config(current_input_config->identifier); 18 struct input_config *new_config =
19 new_input_config(current_input_config->identifier);
17 20
18 if (strcasecmp(argv[0], "none") == 0) { 21 if (strcasecmp(argv[0], "none") == 0) {
19 new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_NONE; 22 new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_NONE;
@@ -22,7 +25,8 @@ struct cmd_results *input_cmd_click_method(int argc, char **argv) {
22 } else if (strcasecmp(argv[0], "clickfinger") == 0) { 25 } else if (strcasecmp(argv[0], "clickfinger") == 0) {
23 new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; 26 new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
24 } else { 27 } else {
25 return cmd_results_new(CMD_INVALID, "click_method", "Expected 'click_method <none|button_areas|clickfinger'"); 28 return cmd_results_new(CMD_INVALID, "click_method",
29 "Expected 'click_method <none|button_areas|clickfinger'");
26 } 30 }
27 31
28 input_cmd_apply(new_config); 32 input_cmd_apply(new_config);
diff --git a/sway/commands/input/drag_lock.c b/sway/commands/input/drag_lock.c
index 11e7fbea..149a6183 100644
--- a/sway/commands/input/drag_lock.c
+++ b/sway/commands/input/drag_lock.c
@@ -9,16 +9,19 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
9 return error; 9 return error;
10 } 10 }
11 if (!current_input_config) { 11 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "drag_lock", "No input device defined."); 12 return cmd_results_new(CMD_FAILURE,
13 "drag_lock", "No input device defined.");
13 } 14 }
14 struct input_config *new_config = new_input_config(current_input_config->identifier); 15 struct input_config *new_config =
16 new_input_config(current_input_config->identifier);
15 17
16 if (strcasecmp(argv[0], "enabled") == 0) { 18 if (strcasecmp(argv[0], "enabled") == 0) {
17 new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_ENABLED; 19 new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_ENABLED;
18 } else if (strcasecmp(argv[0], "disabled") == 0) { 20 } else if (strcasecmp(argv[0], "disabled") == 0) {
19 new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED; 21 new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED;
20 } else { 22 } else {
21 return cmd_results_new(CMD_INVALID, "drag_lock", "Expected 'drag_lock <enabled|disabled>'"); 23 return cmd_results_new(CMD_INVALID, "drag_lock",
24 "Expected 'drag_lock <enabled|disabled>'");
22 } 25 }
23 26
24 input_cmd_apply(new_config); 27 input_cmd_apply(new_config);
diff --git a/sway/commands/input/dwt.c b/sway/commands/input/dwt.c
index f3cbf252..0954575c 100644
--- a/sway/commands/input/dwt.c
+++ b/sway/commands/input/dwt.c
@@ -11,14 +11,16 @@ struct cmd_results *input_cmd_dwt(int argc, char **argv) {
11 if (!current_input_config) { 11 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "dwt", "No input device defined."); 12 return cmd_results_new(CMD_FAILURE, "dwt", "No input device defined.");
13 } 13 }
14 struct input_config *new_config = new_input_config(current_input_config->identifier); 14 struct input_config *new_config =
15 new_input_config(current_input_config->identifier);
15 16
16 if (strcasecmp(argv[0], "enabled") == 0) { 17 if (strcasecmp(argv[0], "enabled") == 0) {
17 new_config->dwt = LIBINPUT_CONFIG_DWT_ENABLED; 18 new_config->dwt = LIBINPUT_CONFIG_DWT_ENABLED;
18 } else if (strcasecmp(argv[0], "disabled") == 0) { 19 } else if (strcasecmp(argv[0], "disabled") == 0) {
19 new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED; 20 new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED;
20 } else { 21 } else {
21 return cmd_results_new(CMD_INVALID, "dwt", "Expected 'dwt <enabled|disabled>'"); 22 return cmd_results_new(CMD_INVALID, "dwt",
23 "Expected 'dwt <enabled|disabled>'");
22 } 24 }
23 25
24 input_cmd_apply(new_config); 26 input_cmd_apply(new_config);
diff --git a/sway/commands/input/events.c b/sway/commands/input/events.c
index 4b2fdff5..f44c0ec7 100644
--- a/sway/commands/input/events.c
+++ b/sway/commands/input/events.c
@@ -5,24 +5,29 @@
5#include "log.h" 5#include "log.h"
6 6
7struct cmd_results *input_cmd_events(int argc, char **argv) { 7struct cmd_results *input_cmd_events(int argc, char **argv) {
8 sway_log(L_DEBUG, "events for device: %s", current_input_config->identifier); 8 sway_log(L_DEBUG, "events for device: %s",
9 current_input_config->identifier);
9 struct cmd_results *error = NULL; 10 struct cmd_results *error = NULL;
10 if ((error = checkarg(argc, "events", EXPECTED_AT_LEAST, 1))) { 11 if ((error = checkarg(argc, "events", EXPECTED_AT_LEAST, 1))) {
11 return error; 12 return error;
12 } 13 }
13 if (!current_input_config) { 14 if (!current_input_config) {
14 return cmd_results_new(CMD_FAILURE, "events", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "events",
16 "No input device defined.");
15 } 17 }
16 struct input_config *new_config = new_input_config(current_input_config->identifier); 18 struct input_config *new_config =
19 new_input_config(current_input_config->identifier);
17 20
18 if (strcasecmp(argv[0], "enabled") == 0) { 21 if (strcasecmp(argv[0], "enabled") == 0) {
19 new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; 22 new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
20 } else if (strcasecmp(argv[0], "disabled") == 0) { 23 } else if (strcasecmp(argv[0], "disabled") == 0) {
21 new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED; 24 new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
22 } else if (strcasecmp(argv[0], "disabled_on_external_mouse") == 0) { 25 } else if (strcasecmp(argv[0], "disabled_on_external_mouse") == 0) {
23 new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE; 26 new_config->send_events =
27 LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE;
24 } else { 28 } else {
25 return cmd_results_new(CMD_INVALID, "events", "Expected 'events <enabled|disabled|disabled_on_external_mouse>'"); 29 return cmd_results_new(CMD_INVALID, "events",
30 "Expected 'events <enabled|disabled|disabled_on_external_mouse>'");
26 } 31 }
27 32
28 input_cmd_apply(new_config); 33 input_cmd_apply(new_config);
diff --git a/sway/commands/input/left_handed.c b/sway/commands/input/left_handed.c
index 715df2a1..dc8fcd56 100644
--- a/sway/commands/input/left_handed.c
+++ b/sway/commands/input/left_handed.c
@@ -9,16 +9,19 @@ struct cmd_results *input_cmd_left_handed(int argc, char **argv) {
9 return error; 9 return error;
10 } 10 }
11 if (!current_input_config) { 11 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "left_handed", "No input device defined."); 12 return cmd_results_new(CMD_FAILURE, "left_handed",
13 "No input device defined.");
13 } 14 }
14 struct input_config *new_config = new_input_config(current_input_config->identifier); 15 struct input_config *new_config =
16 new_input_config(current_input_config->identifier);
15 17
16 if (strcasecmp(argv[0], "enabled") == 0) { 18 if (strcasecmp(argv[0], "enabled") == 0) {
17 new_config->left_handed = 1; 19 new_config->left_handed = 1;
18 } else if (strcasecmp(argv[0], "disabled") == 0) { 20 } else if (strcasecmp(argv[0], "disabled") == 0) {
19 new_config->left_handed = 0; 21 new_config->left_handed = 0;
20 } else { 22 } else {
21 return cmd_results_new(CMD_INVALID, "left_handed", "Expected 'left_handed <enabled|disabled>'"); 23 return cmd_results_new(CMD_INVALID, "left_handed",
24 "Expected 'left_handed <enabled|disabled>'");
22 } 25 }
23 26
24 input_cmd_apply(new_config); 27 input_cmd_apply(new_config);
diff --git a/sway/commands/input/middle_emulation.c b/sway/commands/input/middle_emulation.c
index d31ce950..e19964d8 100644
--- a/sway/commands/input/middle_emulation.c
+++ b/sway/commands/input/middle_emulation.c
@@ -9,16 +9,20 @@ struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
9 return error; 9 return error;
10 } 10 }
11 if (!current_input_config) { 11 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "middle_emulation", "No input device defined."); 12 return cmd_results_new(CMD_FAILURE, "middle_emulation",
13 "No input device defined.");
13 } 14 }
14 struct input_config *new_config = new_input_config(current_input_config->identifier); 15 struct input_config *new_config =
16 new_input_config(current_input_config->identifier);
15 17
16 if (strcasecmp(argv[0], "enabled") == 0) { 18 if (strcasecmp(argv[0], "enabled") == 0) {
17 new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED; 19 new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED;
18 } else if (strcasecmp(argv[0], "disabled") == 0) { 20 } else if (strcasecmp(argv[0], "disabled") == 0) {
19 new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED; 21 new_config->middle_emulation =
22 LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
20 } else { 23 } else {
21 return cmd_results_new(CMD_INVALID, "middle_emulation", "Expected 'middle_emulation <enabled|disabled>'"); 24 return cmd_results_new(CMD_INVALID, "middle_emulation",
25 "Expected 'middle_emulation <enabled|disabled>'");
22 } 26 }
23 27
24 input_cmd_apply(new_config); 28 input_cmd_apply(new_config);
diff --git a/sway/commands/input/natural_scroll.c b/sway/commands/input/natural_scroll.c
index 9d1dc506..8272c5b3 100644
--- a/sway/commands/input/natural_scroll.c
+++ b/sway/commands/input/natural_scroll.c
@@ -9,16 +9,19 @@ struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) {
9 return error; 9 return error;
10 } 10 }
11 if (!current_input_config) { 11 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "natural_scoll", "No input device defined."); 12 return cmd_results_new(CMD_FAILURE, "natural_scoll",
13 "No input device defined.");
13 } 14 }
14 struct input_config *new_config = new_input_config(current_input_config->identifier); 15 struct input_config *new_config =
16 new_input_config(current_input_config->identifier);
15 17
16 if (strcasecmp(argv[0], "enabled") == 0) { 18 if (strcasecmp(argv[0], "enabled") == 0) {
17 new_config->natural_scroll = 1; 19 new_config->natural_scroll = 1;
18 } else if (strcasecmp(argv[0], "disabled") == 0) { 20 } else if (strcasecmp(argv[0], "disabled") == 0) {
19 new_config->natural_scroll = 0; 21 new_config->natural_scroll = 0;
20 } else { 22 } else {
21 return cmd_results_new(CMD_INVALID, "natural_scroll", "Expected 'natural_scroll <enabled|disabled>'"); 23 return cmd_results_new(CMD_INVALID, "natural_scroll",
24 "Expected 'natural_scroll <enabled|disabled>'");
22 } 25 }
23 26
24 input_cmd_apply(new_config); 27 input_cmd_apply(new_config);
diff --git a/sway/commands/input/pointer_accel.c b/sway/commands/input/pointer_accel.c
index 87fb5cff..2c9db5bf 100644
--- a/sway/commands/input/pointer_accel.c
+++ b/sway/commands/input/pointer_accel.c
@@ -9,13 +9,16 @@ struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) {
9 return error; 9 return error;
10 } 10 }
11 if (!current_input_config) { 11 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "pointer_accel", "No input device defined."); 12 return cmd_results_new(CMD_FAILURE,
13 "pointer_accel", "No input device defined.");
13 } 14 }
14 struct input_config *new_config = new_input_config(current_input_config->identifier); 15 struct input_config *new_config =
16 new_input_config(current_input_config->identifier);
15 17
16 float pointer_accel = atof(argv[0]); 18 float pointer_accel = atof(argv[0]);
17 if (pointer_accel < -1 || pointer_accel > 1) { 19 if (pointer_accel < -1 || pointer_accel > 1) {
18 return cmd_results_new(CMD_INVALID, "pointer_accel", "Input out of range [-1, 1]"); 20 return cmd_results_new(CMD_INVALID, "pointer_accel",
21 "Input out of range [-1, 1]");
19 } 22 }
20 new_config->pointer_accel = pointer_accel; 23 new_config->pointer_accel = pointer_accel;
21 24
diff --git a/sway/commands/input/scroll_method.c b/sway/commands/input/scroll_method.c
index 98873938..40277155 100644
--- a/sway/commands/input/scroll_method.c
+++ b/sway/commands/input/scroll_method.c
@@ -9,9 +9,11 @@ struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
9 return error; 9 return error;
10 } 10 }
11 if (!current_input_config) { 11 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "scroll_method", "No input device defined."); 12 return cmd_results_new(CMD_FAILURE, "scroll_method",
13 "No input device defined.");
13 } 14 }
14 struct input_config *new_config = new_input_config(current_input_config->identifier); 15 struct input_config *new_config =
16 new_input_config(current_input_config->identifier);
15 17
16 if (strcasecmp(argv[0], "none") == 0) { 18 if (strcasecmp(argv[0], "none") == 0) {
17 new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL; 19 new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
@@ -22,7 +24,8 @@ struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
22 } else if (strcasecmp(argv[0], "on_button_down") == 0) { 24 } else if (strcasecmp(argv[0], "on_button_down") == 0) {
23 new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; 25 new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
24 } else { 26 } else {
25 return cmd_results_new(CMD_INVALID, "scroll_method", "Expected 'scroll_method <none|two_finger|edge|on_button_down>'"); 27 return cmd_results_new(CMD_INVALID, "scroll_method",
28 "Expected 'scroll_method <none|two_finger|edge|on_button_down>'");
26 } 29 }
27 30
28 input_cmd_apply(new_config); 31 input_cmd_apply(new_config);
diff --git a/sway/commands/input/tap.c b/sway/commands/input/tap.c
index 1109466f..18a54087 100644
--- a/sway/commands/input/tap.c
+++ b/sway/commands/input/tap.c
@@ -13,17 +13,20 @@ struct cmd_results *input_cmd_tap(int argc, char **argv) {
13 if (!current_input_config) { 13 if (!current_input_config) {
14 return cmd_results_new(CMD_FAILURE, "tap", "No input device defined."); 14 return cmd_results_new(CMD_FAILURE, "tap", "No input device defined.");
15 } 15 }
16 struct input_config *new_config = new_input_config(current_input_config->identifier); 16 struct input_config *new_config =
17 new_input_config(current_input_config->identifier);
17 18
18 if (strcasecmp(argv[0], "enabled") == 0) { 19 if (strcasecmp(argv[0], "enabled") == 0) {
19 new_config->tap = LIBINPUT_CONFIG_TAP_ENABLED; 20 new_config->tap = LIBINPUT_CONFIG_TAP_ENABLED;
20 } else if (strcasecmp(argv[0], "disabled") == 0) { 21 } else if (strcasecmp(argv[0], "disabled") == 0) {
21 new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED; 22 new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED;
22 } else { 23 } else {
23 return cmd_results_new(CMD_INVALID, "tap", "Expected 'tap <enabled|disabled>'"); 24 return cmd_results_new(CMD_INVALID, "tap",
25 "Expected 'tap <enabled|disabled>'");
24 } 26 }
25 27
26 sway_log(L_DEBUG, "apply-tap for device: %s", current_input_config->identifier); 28 sway_log(L_DEBUG, "apply-tap for device: %s",
29 current_input_config->identifier);
27 input_cmd_apply(new_config); 30 input_cmd_apply(new_config);
28 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 31 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
29} 32}