aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-07-14 01:01:47 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-07-14 01:01:47 -0400
commit13c6627ddb7dbe235426e123ee6ff8e6794bda6d (patch)
tree078891937a369fae4a7399374c58c3352734f199 /sway/commands
parentMerge pull request #2244 from RyanDwyer/floating-resize (diff)
downloadsway-13c6627ddb7dbe235426e123ee6ff8e6794bda6d.tar.gz
sway-13c6627ddb7dbe235426e123ee6ff8e6794bda6d.tar.zst
sway-13c6627ddb7dbe235426e123ee6ff8e6794bda6d.zip
Implement tap_button_map for input devices
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/input.c1
-rw-r--r--sway/commands/input/tap_button_map.c33
2 files changed, 34 insertions, 0 deletions
diff --git a/sway/commands/input.c b/sway/commands/input.c
index e7906b0e..5b203ea0 100644
--- a/sway/commands/input.c
+++ b/sway/commands/input.c
@@ -23,6 +23,7 @@ static struct cmd_handler input_handlers[] = {
23 { "scroll_button", input_cmd_scroll_button }, 23 { "scroll_button", input_cmd_scroll_button },
24 { "scroll_method", input_cmd_scroll_method }, 24 { "scroll_method", input_cmd_scroll_method },
25 { "tap", input_cmd_tap }, 25 { "tap", input_cmd_tap },
26 { "tap_button_map", input_cmd_tap_button_map },
26 { "xkb_layout", input_cmd_xkb_layout }, 27 { "xkb_layout", input_cmd_xkb_layout },
27 { "xkb_model", input_cmd_xkb_model }, 28 { "xkb_model", input_cmd_xkb_model },
28 { "xkb_options", input_cmd_xkb_options }, 29 { "xkb_options", input_cmd_xkb_options },
diff --git a/sway/commands/input/tap_button_map.c b/sway/commands/input/tap_button_map.c
new file mode 100644
index 00000000..bdbba472
--- /dev/null
+++ b/sway/commands/input/tap_button_map.c
@@ -0,0 +1,33 @@
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_tap_button_map(int argc, char **argv) {
8 struct cmd_results *error = NULL;
9 if ((error = checkarg(argc, "tap_button_map", EXPECTED_AT_LEAST, 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, "tap_button_map",
16 "No input device defined.");
17 }
18 struct input_config *new_config =
19 new_input_config(current_input_config->identifier);
20
21 if (strcasecmp(argv[0], "lrm") == 0) {
22 new_config->tap_button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
23 } else if (strcasecmp(argv[0], "lmr") == 0) {
24 new_config->tap_button_map = LIBINPUT_CONFIG_TAP_MAP_LMR;
25 } else {
26 free_input_config(new_config);
27 return cmd_results_new(CMD_INVALID, "tap_button_map",
28 "Expected 'tap_button_map <lrm|lmr>'");
29 }
30
31 apply_input_config(new_config);
32 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
33}