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