diff options
Diffstat (limited to 'sway/commands/input/natural_scroll.c')
-rw-r--r-- | sway/commands/input/natural_scroll.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sway/commands/input/natural_scroll.c b/sway/commands/input/natural_scroll.c new file mode 100644 index 00000000..a7dcdc2c --- /dev/null +++ b/sway/commands/input/natural_scroll.c | |||
@@ -0,0 +1,30 @@ | |||
1 | #include <string.h> | ||
2 | #include <strings.h> | ||
3 | #include "sway/config.h" | ||
4 | #include "sway/commands.h" | ||
5 | #include "sway/input/input-manager.h" | ||
6 | |||
7 | struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) { | ||
8 | struct cmd_results *error = NULL; | ||
9 | if ((error = checkarg(argc, "natural_scroll", EXPECTED_AT_LEAST, 1))) { | ||
10 | return error; | ||
11 | } | ||
12 | if (!current_input_config) { | ||
13 | return cmd_results_new(CMD_FAILURE, "natural_scoll", | ||
14 | "No input device defined."); | ||
15 | } | ||
16 | struct input_config *new_config = | ||
17 | new_input_config(current_input_config->identifier); | ||
18 | |||
19 | if (strcasecmp(argv[0], "enabled") == 0) { | ||
20 | new_config->natural_scroll = 1; | ||
21 | } else if (strcasecmp(argv[0], "disabled") == 0) { | ||
22 | new_config->natural_scroll = 0; | ||
23 | } else { | ||
24 | return cmd_results_new(CMD_INVALID, "natural_scroll", | ||
25 | "Expected 'natural_scroll <enabled|disabled>'"); | ||
26 | } | ||
27 | |||
28 | apply_input_config(new_config); | ||
29 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
30 | } | ||