summaryrefslogtreecommitdiffstats
path: root/sway/commands/input
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/input')
-rw-r--r--sway/commands/input/accel_profile.c13
-rw-r--r--sway/commands/input/click_method.c17
-rw-r--r--sway/commands/input/drag_lock.c16
-rw-r--r--sway/commands/input/dwt.c13
-rw-r--r--sway/commands/input/events.c22
-rw-r--r--sway/commands/input/left_handed.c16
-rw-r--r--sway/commands/input/map_to_output.c27
-rw-r--r--sway/commands/input/middle_emulation.c19
-rw-r--r--sway/commands/input/natural_scroll.c16
-rw-r--r--sway/commands/input/pointer_accel.c16
-rw-r--r--sway/commands/input/scroll_method.c16
-rw-r--r--sway/commands/input/tap.c17
-rw-r--r--sway/commands/input/xkb_layout.c26
-rw-r--r--sway/commands/input/xkb_model.c26
-rw-r--r--sway/commands/input/xkb_options.c26
-rw-r--r--sway/commands/input/xkb_rules.c26
-rw-r--r--sway/commands/input/xkb_variant.c26
17 files changed, 280 insertions, 58 deletions
diff --git a/sway/commands/input/accel_profile.c b/sway/commands/input/accel_profile.c
index 8288c1ad..37d6e133 100644
--- a/sway/commands/input/accel_profile.c
+++ b/sway/commands/input/accel_profile.c
@@ -1,17 +1,22 @@
1#include <string.h> 1#include <string.h>
2#include <strings.h> 2#include <strings.h>
3#include "sway/config.h"
3#include "sway/commands.h" 4#include "sway/commands.h"
4#include "sway/input.h" 5#include "sway/input/input-manager.h"
5 6
6struct cmd_results *input_cmd_accel_profile(int argc, char **argv) { 7struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
7 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
8 if ((error = checkarg(argc, "accel_profile", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "accel_profile", EXPECTED_AT_LEAST, 1))) {
9 return error; 10 return error;
10 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
11 if (!current_input_config) { 14 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "accel_profile", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "accel_profile",
16 "No input device defined.");
13 } 17 }
14 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);
15 20
16 if (strcasecmp(argv[0], "adaptive") == 0) { 21 if (strcasecmp(argv[0], "adaptive") == 0) {
17 new_config->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE; 22 new_config->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
@@ -22,6 +27,6 @@ struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
22 "Expected 'accel_profile <adaptive|flat>'"); 27 "Expected 'accel_profile <adaptive|flat>'");
23 } 28 }
24 29
25 input_cmd_apply(new_config); 30 apply_input_config(new_config);
26 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 31 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
27} 32}
diff --git a/sway/commands/input/click_method.c b/sway/commands/input/click_method.c
index 5e9d3dcb..8f1f0aa7 100644
--- a/sway/commands/input/click_method.c
+++ b/sway/commands/input/click_method.c
@@ -1,19 +1,23 @@
1#include <string.h> 1#include <string.h>
2#include <strings.h> 2#include <strings.h>
3#include "sway/commands.h" 3#include "sway/commands.h"
4#include "sway/input.h" 4#include "sway/config.h"
5#include "sway/input/input-manager.h"
5#include "log.h" 6#include "log.h"
6 7
7struct cmd_results *input_cmd_click_method(int argc, char **argv) { 8struct 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);
9 struct cmd_results *error = NULL; 9 struct cmd_results *error = NULL;
10 if ((error = checkarg(argc, "click_method", EXPECTED_AT_LEAST, 1))) { 10 if ((error = checkarg(argc, "click_method", EXPECTED_AT_LEAST, 1))) {
11 return error; 11 return error;
12 } 12 }
13 struct input_config *current_input_config =
14 config->handler_context.input_config;
13 if (!current_input_config) { 15 if (!current_input_config) {
14 return cmd_results_new(CMD_FAILURE, "click_method", "No input device defined."); 16 return cmd_results_new(CMD_FAILURE, "click_method",
17 "No input device defined.");
15 } 18 }
16 struct input_config *new_config = new_input_config(current_input_config->identifier); 19 struct input_config *new_config =
20 new_input_config(current_input_config->identifier);
17 21
18 if (strcasecmp(argv[0], "none") == 0) { 22 if (strcasecmp(argv[0], "none") == 0) {
19 new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_NONE; 23 new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_NONE;
@@ -22,9 +26,10 @@ struct cmd_results *input_cmd_click_method(int argc, char **argv) {
22 } else if (strcasecmp(argv[0], "clickfinger") == 0) { 26 } else if (strcasecmp(argv[0], "clickfinger") == 0) {
23 new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; 27 new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
24 } else { 28 } else {
25 return cmd_results_new(CMD_INVALID, "click_method", "Expected 'click_method <none|button_areas|clickfinger'"); 29 return cmd_results_new(CMD_INVALID, "click_method",
30 "Expected 'click_method <none|button_areas|clickfinger'");
26 } 31 }
27 32
28 input_cmd_apply(new_config); 33 apply_input_config(new_config);
29 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 34 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
30} 35}
diff --git a/sway/commands/input/drag_lock.c b/sway/commands/input/drag_lock.c
index f5a7beb4..8273a7d4 100644
--- a/sway/commands/input/drag_lock.c
+++ b/sway/commands/input/drag_lock.c
@@ -1,26 +1,32 @@
1#include <string.h> 1#include <string.h>
2#include <strings.h> 2#include <strings.h>
3#include "sway/config.h"
3#include "sway/commands.h" 4#include "sway/commands.h"
4#include "sway/input.h" 5#include "sway/input/input-manager.h"
5 6
6struct cmd_results *input_cmd_drag_lock(int argc, char **argv) { 7struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
7 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
8 if ((error = checkarg(argc, "drag_lock", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "drag_lock", EXPECTED_AT_LEAST, 1))) {
9 return error; 10 return error;
10 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
11 if (!current_input_config) { 14 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "drag_lock", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE,
16 "drag_lock", "No input device defined.");
13 } 17 }
14 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);
15 20
16 if (strcasecmp(argv[0], "enabled") == 0) { 21 if (strcasecmp(argv[0], "enabled") == 0) {
17 new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_ENABLED; 22 new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_ENABLED;
18 } else if (strcasecmp(argv[0], "disabled") == 0) { 23 } else if (strcasecmp(argv[0], "disabled") == 0) {
19 new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED; 24 new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED;
20 } else { 25 } else {
21 return cmd_results_new(CMD_INVALID, "drag_lock", "Expected 'drag_lock <enabled|disabled>'"); 26 return cmd_results_new(CMD_INVALID, "drag_lock",
27 "Expected 'drag_lock <enabled|disabled>'");
22 } 28 }
23 29
24 input_cmd_apply(new_config); 30 apply_input_config(new_config);
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 31 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
26} 32}
diff --git a/sway/commands/input/dwt.c b/sway/commands/input/dwt.c
index 557b2207..995a2f47 100644
--- a/sway/commands/input/dwt.c
+++ b/sway/commands/input/dwt.c
@@ -1,26 +1,31 @@
1#include <string.h> 1#include <string.h>
2#include <strings.h> 2#include <strings.h>
3#include "sway/config.h"
3#include "sway/commands.h" 4#include "sway/commands.h"
4#include "sway/input.h" 5#include "sway/input/input-manager.h"
5 6
6struct cmd_results *input_cmd_dwt(int argc, char **argv) { 7struct cmd_results *input_cmd_dwt(int argc, char **argv) {
7 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
8 if ((error = checkarg(argc, "dwt", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "dwt", EXPECTED_AT_LEAST, 1))) {
9 return error; 10 return error;
10 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
11 if (!current_input_config) { 14 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "dwt", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "dwt", "No input device defined.");
13 } 16 }
14 struct input_config *new_config = new_input_config(current_input_config->identifier); 17 struct input_config *new_config =
18 new_input_config(current_input_config->identifier);
15 19
16 if (strcasecmp(argv[0], "enabled") == 0) { 20 if (strcasecmp(argv[0], "enabled") == 0) {
17 new_config->dwt = LIBINPUT_CONFIG_DWT_ENABLED; 21 new_config->dwt = LIBINPUT_CONFIG_DWT_ENABLED;
18 } else if (strcasecmp(argv[0], "disabled") == 0) { 22 } else if (strcasecmp(argv[0], "disabled") == 0) {
19 new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED; 23 new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED;
20 } else { 24 } else {
21 return cmd_results_new(CMD_INVALID, "dwt", "Expected 'dwt <enabled|disabled>'"); 25 return cmd_results_new(CMD_INVALID, "dwt",
26 "Expected 'dwt <enabled|disabled>'");
22 } 27 }
23 28
24 input_cmd_apply(new_config); 29 apply_input_config(new_config);
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 30 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
26} 31}
diff --git a/sway/commands/input/events.c b/sway/commands/input/events.c
index 9d54287a..2217f5ce 100644
--- a/sway/commands/input/events.c
+++ b/sway/commands/input/events.c
@@ -1,30 +1,38 @@
1#include <string.h> 1#include <string.h>
2#include <strings.h> 2#include <strings.h>
3#include "sway/config.h"
3#include "sway/commands.h" 4#include "sway/commands.h"
4#include "sway/input.h" 5#include "sway/input/input-manager.h"
5#include "log.h" 6#include "log.h"
6 7
7struct cmd_results *input_cmd_events(int argc, char **argv) { 8struct cmd_results *input_cmd_events(int argc, char **argv) {
8 sway_log(L_DEBUG, "events for device: %s", current_input_config->identifier);
9 struct cmd_results *error = NULL; 9 struct cmd_results *error = NULL;
10 if ((error = checkarg(argc, "events", EXPECTED_AT_LEAST, 1))) { 10 if ((error = checkarg(argc, "events", EXPECTED_AT_LEAST, 1))) {
11 return error; 11 return error;
12 } 12 }
13 struct input_config *current_input_config =
14 config->handler_context.input_config;
13 if (!current_input_config) { 15 if (!current_input_config) {
14 return cmd_results_new(CMD_FAILURE, "events", "No input device defined."); 16 return cmd_results_new(CMD_FAILURE, "events",
17 "No input device defined.");
15 } 18 }
16 struct input_config *new_config = new_input_config(current_input_config->identifier); 19 wlr_log(L_DEBUG, "events for device: %s",
20 current_input_config->identifier);
21 struct input_config *new_config =
22 new_input_config(current_input_config->identifier);
17 23
18 if (strcasecmp(argv[0], "enabled") == 0) { 24 if (strcasecmp(argv[0], "enabled") == 0) {
19 new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; 25 new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
20 } else if (strcasecmp(argv[0], "disabled") == 0) { 26 } else if (strcasecmp(argv[0], "disabled") == 0) {
21 new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED; 27 new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
22 } else if (strcasecmp(argv[0], "disabled_on_external_mouse") == 0) { 28 } else if (strcasecmp(argv[0], "disabled_on_external_mouse") == 0) {
23 new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE; 29 new_config->send_events =
30 LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE;
24 } else { 31 } else {
25 return cmd_results_new(CMD_INVALID, "events", "Expected 'events <enabled|disabled|disabled_on_external_mouse>'"); 32 return cmd_results_new(CMD_INVALID, "events",
33 "Expected 'events <enabled|disabled|disabled_on_external_mouse>'");
26 } 34 }
27 35
28 input_cmd_apply(new_config); 36 apply_input_config(new_config);
29 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 37 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
30} 38}
diff --git a/sway/commands/input/left_handed.c b/sway/commands/input/left_handed.c
index 6c913e70..94b8e03e 100644
--- a/sway/commands/input/left_handed.c
+++ b/sway/commands/input/left_handed.c
@@ -1,26 +1,32 @@
1#include <string.h> 1#include <string.h>
2#include <strings.h> 2#include <strings.h>
3#include "sway/config.h"
3#include "sway/commands.h" 4#include "sway/commands.h"
4#include "sway/input.h" 5#include "sway/input/input-manager.h"
5 6
6struct cmd_results *input_cmd_left_handed(int argc, char **argv) { 7struct cmd_results *input_cmd_left_handed(int argc, char **argv) {
7 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
8 if ((error = checkarg(argc, "left_handed", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "left_handed", EXPECTED_AT_LEAST, 1))) {
9 return error; 10 return error;
10 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
11 if (!current_input_config) { 14 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "left_handed", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "left_handed",
16 "No input device defined.");
13 } 17 }
14 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);
15 20
16 if (strcasecmp(argv[0], "enabled") == 0) { 21 if (strcasecmp(argv[0], "enabled") == 0) {
17 new_config->left_handed = 1; 22 new_config->left_handed = 1;
18 } else if (strcasecmp(argv[0], "disabled") == 0) { 23 } else if (strcasecmp(argv[0], "disabled") == 0) {
19 new_config->left_handed = 0; 24 new_config->left_handed = 0;
20 } else { 25 } else {
21 return cmd_results_new(CMD_INVALID, "left_handed", "Expected 'left_handed <enabled|disabled>'"); 26 return cmd_results_new(CMD_INVALID, "left_handed",
27 "Expected 'left_handed <enabled|disabled>'");
22 } 28 }
23 29
24 input_cmd_apply(new_config); 30 apply_input_config(new_config);
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 31 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
26} 32}
diff --git a/sway/commands/input/map_to_output.c b/sway/commands/input/map_to_output.c
new file mode 100644
index 00000000..60e4608e
--- /dev/null
+++ b/sway/commands/input/map_to_output.c
@@ -0,0 +1,27 @@
1#define _POSIX_C_SOURCE 200809L
2#include <string.h>
3#include <strings.h>
4#include "sway/config.h"
5#include "sway/commands.h"
6#include "sway/input/input-manager.h"
7#include "log.h"
8
9struct cmd_results *input_cmd_map_to_output(int argc, char **argv) {
10 struct cmd_results *error = NULL;
11 if ((error = checkarg(argc, "map_to_output", EXPECTED_EQUAL_TO, 1))) {
12 return error;
13 }
14 struct input_config *current_input_config =
15 config->handler_context.input_config;
16 if (!current_input_config) {
17 return cmd_results_new(CMD_FAILURE, "map_to_output",
18 "No input device defined.");
19 }
20 struct input_config *new_config =
21 new_input_config(current_input_config->identifier);
22
23 new_config->mapped_output = strdup(argv[0]);
24 apply_input_config(new_config);
25
26 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
27}
diff --git a/sway/commands/input/middle_emulation.c b/sway/commands/input/middle_emulation.c
index 33cdd7d6..a551fd51 100644
--- a/sway/commands/input/middle_emulation.c
+++ b/sway/commands/input/middle_emulation.c
@@ -1,26 +1,33 @@
1#include <string.h> 1#include <string.h>
2#include <strings.h> 2#include <strings.h>
3#include "sway/config.h"
3#include "sway/commands.h" 4#include "sway/commands.h"
4#include "sway/input.h" 5#include "sway/input/input-manager.h"
5 6
6struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) { 7struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
7 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
8 if ((error = checkarg(argc, "middle_emulation", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "middle_emulation", EXPECTED_AT_LEAST, 1))) {
9 return error; 10 return error;
10 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
11 if (!current_input_config) { 14 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "middle_emulation", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "middle_emulation",
16 "No input device defined.");
13 } 17 }
14 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);
15 20
16 if (strcasecmp(argv[0], "enabled") == 0) { 21 if (strcasecmp(argv[0], "enabled") == 0) {
17 new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED; 22 new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED;
18 } else if (strcasecmp(argv[0], "disabled") == 0) { 23 } else if (strcasecmp(argv[0], "disabled") == 0) {
19 new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED; 24 new_config->middle_emulation =
25 LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
20 } else { 26 } else {
21 return cmd_results_new(CMD_INVALID, "middle_emulation", "Expected 'middle_emulation <enabled|disabled>'"); 27 return cmd_results_new(CMD_INVALID, "middle_emulation",
28 "Expected 'middle_emulation <enabled|disabled>'");
22 } 29 }
23 30
24 input_cmd_apply(new_config); 31 apply_input_config(new_config);
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 32 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
26} 33}
diff --git a/sway/commands/input/natural_scroll.c b/sway/commands/input/natural_scroll.c
index 7bc8b8d0..c4e19b78 100644
--- a/sway/commands/input/natural_scroll.c
+++ b/sway/commands/input/natural_scroll.c
@@ -1,26 +1,32 @@
1#include <string.h> 1#include <string.h>
2#include <strings.h> 2#include <strings.h>
3#include "sway/config.h"
3#include "sway/commands.h" 4#include "sway/commands.h"
4#include "sway/input.h" 5#include "sway/input/input-manager.h"
5 6
6struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) { 7struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) {
7 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
8 if ((error = checkarg(argc, "natural_scroll", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "natural_scroll", EXPECTED_AT_LEAST, 1))) {
9 return error; 10 return error;
10 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
11 if (!current_input_config) { 14 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "natural_scoll", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "natural_scoll",
16 "No input device defined.");
13 } 17 }
14 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);
15 20
16 if (strcasecmp(argv[0], "enabled") == 0) { 21 if (strcasecmp(argv[0], "enabled") == 0) {
17 new_config->natural_scroll = 1; 22 new_config->natural_scroll = 1;
18 } else if (strcasecmp(argv[0], "disabled") == 0) { 23 } else if (strcasecmp(argv[0], "disabled") == 0) {
19 new_config->natural_scroll = 0; 24 new_config->natural_scroll = 0;
20 } else { 25 } else {
21 return cmd_results_new(CMD_INVALID, "natural_scroll", "Expected 'natural_scroll <enabled|disabled>'"); 26 return cmd_results_new(CMD_INVALID, "natural_scroll",
27 "Expected 'natural_scroll <enabled|disabled>'");
22 } 28 }
23 29
24 input_cmd_apply(new_config); 30 apply_input_config(new_config);
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 31 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
26} 32}
diff --git a/sway/commands/input/pointer_accel.c b/sway/commands/input/pointer_accel.c
index 94f595d1..171063aa 100644
--- a/sway/commands/input/pointer_accel.c
+++ b/sway/commands/input/pointer_accel.c
@@ -1,24 +1,30 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <string.h> 2#include <string.h>
3#include "sway/config.h"
3#include "sway/commands.h" 4#include "sway/commands.h"
4#include "sway/input.h" 5#include "sway/input/input-manager.h"
5 6
6struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) { 7struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) {
7 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
8 if ((error = checkarg(argc, "pointer_accel", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "pointer_accel", EXPECTED_AT_LEAST, 1))) {
9 return error; 10 return error;
10 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
11 if (!current_input_config) { 14 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "pointer_accel", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE,
16 "pointer_accel", "No input device defined.");
13 } 17 }
14 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);
15 20
16 float pointer_accel = atof(argv[0]); 21 float pointer_accel = atof(argv[0]);
17 if (pointer_accel < -1 || pointer_accel > 1) { 22 if (pointer_accel < -1 || pointer_accel > 1) {
18 return cmd_results_new(CMD_INVALID, "pointer_accel", "Input out of range [-1, 1]"); 23 return cmd_results_new(CMD_INVALID, "pointer_accel",
24 "Input out of range [-1, 1]");
19 } 25 }
20 new_config->pointer_accel = pointer_accel; 26 new_config->pointer_accel = pointer_accel;
21 27
22 input_cmd_apply(new_config); 28 apply_input_config(new_config);
23 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 29 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
24} 30}
diff --git a/sway/commands/input/scroll_method.c b/sway/commands/input/scroll_method.c
index 5c6c3d7a..0a1c57ac 100644
--- a/sway/commands/input/scroll_method.c
+++ b/sway/commands/input/scroll_method.c
@@ -1,17 +1,22 @@
1#include <string.h> 1#include <string.h>
2#include <strings.h> 2#include <strings.h>
3#include "sway/config.h"
3#include "sway/commands.h" 4#include "sway/commands.h"
4#include "sway/input.h" 5#include "sway/input/input-manager.h"
5 6
6struct cmd_results *input_cmd_scroll_method(int argc, char **argv) { 7struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
7 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
8 if ((error = checkarg(argc, "scroll_method", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "scroll_method", EXPECTED_AT_LEAST, 1))) {
9 return error; 10 return error;
10 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
11 if (!current_input_config) { 14 if (!current_input_config) {
12 return cmd_results_new(CMD_FAILURE, "scroll_method", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "scroll_method",
16 "No input device defined.");
13 } 17 }
14 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);
15 20
16 if (strcasecmp(argv[0], "none") == 0) { 21 if (strcasecmp(argv[0], "none") == 0) {
17 new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL; 22 new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
@@ -22,9 +27,10 @@ struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
22 } else if (strcasecmp(argv[0], "on_button_down") == 0) { 27 } else if (strcasecmp(argv[0], "on_button_down") == 0) {
23 new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; 28 new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
24 } else { 29 } else {
25 return cmd_results_new(CMD_INVALID, "scroll_method", "Expected 'scroll_method <none|two_finger|edge|on_button_down>'"); 30 return cmd_results_new(CMD_INVALID, "scroll_method",
31 "Expected 'scroll_method <none|two_finger|edge|on_button_down>'");
26 } 32 }
27 33
28 input_cmd_apply(new_config); 34 apply_input_config(new_config);
29 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 35 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
30} 36}
diff --git a/sway/commands/input/tap.c b/sway/commands/input/tap.c
index 9e3ca2af..e7f03058 100644
--- a/sway/commands/input/tap.c
+++ b/sway/commands/input/tap.c
@@ -1,29 +1,34 @@
1#include <string.h> 1#include <string.h>
2#include <strings.h> 2#include <strings.h>
3#include "sway/config.h"
3#include "sway/commands.h" 4#include "sway/commands.h"
4#include "sway/input.h" 5#include "sway/input/input-manager.h"
5#include "log.h" 6#include "log.h"
6 7
7struct cmd_results *input_cmd_tap(int argc, char **argv) { 8struct cmd_results *input_cmd_tap(int argc, char **argv) {
8 sway_log(L_DEBUG, "tap for device: %s", current_input_config->identifier);
9 struct cmd_results *error = NULL; 9 struct cmd_results *error = NULL;
10 if ((error = checkarg(argc, "tap", EXPECTED_AT_LEAST, 1))) { 10 if ((error = checkarg(argc, "tap", EXPECTED_AT_LEAST, 1))) {
11 return error; 11 return error;
12 } 12 }
13 struct input_config *current_input_config =
14 config->handler_context.input_config;
13 if (!current_input_config) { 15 if (!current_input_config) {
14 return cmd_results_new(CMD_FAILURE, "tap", "No input device defined."); 16 return cmd_results_new(CMD_FAILURE, "tap", "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->tap = LIBINPUT_CONFIG_TAP_ENABLED; 22 new_config->tap = LIBINPUT_CONFIG_TAP_ENABLED;
20 } else if (strcasecmp(argv[0], "disabled") == 0) { 23 } else if (strcasecmp(argv[0], "disabled") == 0) {
21 new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED; 24 new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED;
22 } else { 25 } else {
23 return cmd_results_new(CMD_INVALID, "tap", "Expected 'tap <enabled|disabled>'"); 26 return cmd_results_new(CMD_INVALID, "tap",
27 "Expected 'tap <enabled|disabled>'");
24 } 28 }
25 29
26 sway_log(L_DEBUG, "apply-tap for device: %s", current_input_config->identifier); 30 wlr_log(L_DEBUG, "apply-tap for device: %s",
27 input_cmd_apply(new_config); 31 current_input_config->identifier);
32 apply_input_config(new_config);
28 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 33 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
29} 34}
diff --git a/sway/commands/input/xkb_layout.c b/sway/commands/input/xkb_layout.c
new file mode 100644
index 00000000..867e65d3
--- /dev/null
+++ b/sway/commands/input/xkb_layout.c
@@ -0,0 +1,26 @@
1#define _XOPEN_SOURCE 700
2#include "sway/config.h"
3#include "sway/commands.h"
4#include "sway/input/input-manager.h"
5#include "log.h"
6
7struct cmd_results *input_cmd_xkb_layout(int argc, char **argv) {
8 struct cmd_results *error = NULL;
9 if ((error = checkarg(argc, "xkb_layout", EXPECTED_EQUAL_TO, 1))) {
10 return error;
11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
14 if (!current_input_config) {
15 return cmd_results_new(CMD_FAILURE, "xkb_layout", "No input device defined.");
16 }
17 struct input_config *new_config =
18 new_input_config(current_input_config->identifier);
19
20 new_config->xkb_layout = strdup(argv[0]);
21
22 wlr_log(L_DEBUG, "apply-xkb_layout for device: %s layout: %s",
23 current_input_config->identifier, new_config->xkb_layout);
24 apply_input_config(new_config);
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
26}
diff --git a/sway/commands/input/xkb_model.c b/sway/commands/input/xkb_model.c
new file mode 100644
index 00000000..e8c8e04e
--- /dev/null
+++ b/sway/commands/input/xkb_model.c
@@ -0,0 +1,26 @@
1#define _XOPEN_SOURCE 700
2#include "sway/config.h"
3#include "sway/commands.h"
4#include "sway/input/input-manager.h"
5#include "log.h"
6
7struct cmd_results *input_cmd_xkb_model(int argc, char **argv) {
8 struct cmd_results *error = NULL;
9 if ((error = checkarg(argc, "xkb_model", EXPECTED_EQUAL_TO, 1))) {
10 return error;
11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
14 if (!current_input_config) {
15 return cmd_results_new(CMD_FAILURE, "xkb_model", "No input device defined.");
16 }
17 struct input_config *new_config =
18 new_input_config(current_input_config->identifier);
19
20 new_config->xkb_model = strdup(argv[0]);
21
22 wlr_log(L_DEBUG, "apply-xkb_model for device: %s model: %s",
23 current_input_config->identifier, new_config->xkb_model);
24 apply_input_config(new_config);
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
26}
diff --git a/sway/commands/input/xkb_options.c b/sway/commands/input/xkb_options.c
new file mode 100644
index 00000000..e9ddd6e3
--- /dev/null
+++ b/sway/commands/input/xkb_options.c
@@ -0,0 +1,26 @@
1#define _XOPEN_SOURCE 700
2#include "sway/config.h"
3#include "sway/commands.h"
4#include "sway/input/input-manager.h"
5#include "log.h"
6
7struct cmd_results *input_cmd_xkb_options(int argc, char **argv) {
8 struct cmd_results *error = NULL;
9 if ((error = checkarg(argc, "xkb_options", EXPECTED_EQUAL_TO, 1))) {
10 return error;
11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
14 if (!current_input_config) {
15 return cmd_results_new(CMD_FAILURE, "xkb_options", "No input device defined.");
16 }
17 struct input_config *new_config =
18 new_input_config(current_input_config->identifier);
19
20 new_config->xkb_options = strdup(argv[0]);
21
22 wlr_log(L_DEBUG, "apply-xkb_options for device: %s options: %s",
23 current_input_config->identifier, new_config->xkb_options);
24 apply_input_config(new_config);
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
26}
diff --git a/sway/commands/input/xkb_rules.c b/sway/commands/input/xkb_rules.c
new file mode 100644
index 00000000..926d0ac1
--- /dev/null
+++ b/sway/commands/input/xkb_rules.c
@@ -0,0 +1,26 @@
1#define _XOPEN_SOURCE 700
2#include "sway/config.h"
3#include "sway/commands.h"
4#include "sway/input/input-manager.h"
5#include "log.h"
6
7struct cmd_results *input_cmd_xkb_rules(int argc, char **argv) {
8 struct cmd_results *error = NULL;
9 if ((error = checkarg(argc, "xkb_rules", EXPECTED_EQUAL_TO, 1))) {
10 return error;
11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
14 if (!current_input_config) {
15 return cmd_results_new(CMD_FAILURE, "xkb_rules", "No input device defined.");
16 }
17 struct input_config *new_config =
18 new_input_config(current_input_config->identifier);
19
20 new_config->xkb_rules = strdup(argv[0]);
21
22 wlr_log(L_DEBUG, "apply-xkb_rules for device: %s rules: %s",
23 current_input_config->identifier, new_config->xkb_rules);
24 apply_input_config(new_config);
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
26}
diff --git a/sway/commands/input/xkb_variant.c b/sway/commands/input/xkb_variant.c
new file mode 100644
index 00000000..0e3ffd41
--- /dev/null
+++ b/sway/commands/input/xkb_variant.c
@@ -0,0 +1,26 @@
1#define _XOPEN_SOURCE 700
2#include "sway/config.h"
3#include "sway/commands.h"
4#include "sway/input/input-manager.h"
5#include "log.h"
6
7struct cmd_results *input_cmd_xkb_variant(int argc, char **argv) {
8 struct cmd_results *error = NULL;
9 if ((error = checkarg(argc, "xkb_variant", EXPECTED_EQUAL_TO, 1))) {
10 return error;
11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
14 if (!current_input_config) {
15 return cmd_results_new(CMD_FAILURE, "xkb_variant", "No input device defined.");
16 }
17 struct input_config *new_config =
18 new_input_config(current_input_config->identifier);
19
20 new_config->xkb_variant = strdup(argv[0]);
21
22 wlr_log(L_DEBUG, "apply-xkb_variant for device: %s variant: %s",
23 current_input_config->identifier, new_config->xkb_variant);
24 apply_input_config(new_config);
25 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
26}