diff options
Diffstat (limited to 'sway/commands/input/left_handed.c')
-rw-r--r-- | sway/commands/input/left_handed.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sway/commands/input/left_handed.c b/sway/commands/input/left_handed.c new file mode 100644 index 00000000..35740df3 --- /dev/null +++ b/sway/commands/input/left_handed.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_left_handed(int argc, char **argv) { | ||
8 | struct cmd_results *error = NULL; | ||
9 | if ((error = checkarg(argc, "left_handed", EXPECTED_AT_LEAST, 1))) { | ||
10 | return error; | ||
11 | } | ||
12 | if (!current_input_config) { | ||
13 | return cmd_results_new(CMD_FAILURE, "left_handed", | ||
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->left_handed = 1; | ||
21 | } else if (strcasecmp(argv[0], "disabled") == 0) { | ||
22 | new_config->left_handed = 0; | ||
23 | } else { | ||
24 | return cmd_results_new(CMD_INVALID, "left_handed", | ||
25 | "Expected 'left_handed <enabled|disabled>'"); | ||
26 | } | ||
27 | |||
28 | apply_input_config(new_config); | ||
29 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
30 | } | ||