aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Michał Winiarski <knr@hardline.pl>2016-10-25 22:03:58 +0200
committerLibravatar Michał Winiarski <knr@hardline.pl>2016-10-25 22:06:23 +0200
commite8d8abfbb50a8992a0aa1a8c1e7fa99b8aae8248 (patch)
tree6becd3422c2705199ae5e639020f32a9b9f334c9 /sway
parentMerge pull request #958 from Hummer12007/pango (diff)
downloadsway-e8d8abfbb50a8992a0aa1a8c1e7fa99b8aae8248.tar.gz
sway-e8d8abfbb50a8992a0aa1a8c1e7fa99b8aae8248.tar.zst
sway-e8d8abfbb50a8992a0aa1a8c1e7fa99b8aae8248.zip
Add left_handed support for input devices
Some users may want to switch buttons on their input devices, turns out libinput already supports it. Let's add a support for it in our config. Signed-off-by: Michał Winiarski <knr@hardline.pl>
Diffstat (limited to 'sway')
-rw-r--r--sway/commands.c1
-rw-r--r--sway/commands/input.c2
-rw-r--r--sway/commands/input/left_handed.c25
-rw-r--r--sway/config.c4
-rw-r--r--sway/input.c1
-rw-r--r--sway/sway-input.5.txt3
6 files changed, 36 insertions, 0 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 2b91c43e..3236ff6c 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -265,6 +265,7 @@ static struct cmd_handler input_handlers[] = {
265 { "drag_lock", input_cmd_drag_lock }, 265 { "drag_lock", input_cmd_drag_lock },
266 { "dwt", input_cmd_dwt }, 266 { "dwt", input_cmd_dwt },
267 { "events", input_cmd_events }, 267 { "events", input_cmd_events },
268 { "left_handed", input_cmd_left_handed },
268 { "middle_emulation", input_cmd_middle_emulation }, 269 { "middle_emulation", input_cmd_middle_emulation },
269 { "natural_scroll", input_cmd_natural_scroll }, 270 { "natural_scroll", input_cmd_natural_scroll },
270 { "pointer_accel", input_cmd_pointer_accel }, 271 { "pointer_accel", input_cmd_pointer_accel },
diff --git a/sway/commands/input.c b/sway/commands/input.c
index 9c9d7600..f584bb77 100644
--- a/sway/commands/input.c
+++ b/sway/commands/input.c
@@ -31,6 +31,8 @@ struct cmd_results *cmd_input(int argc, char **argv) {
31 res = input_cmd_dwt(argc_new, argv_new); 31 res = input_cmd_dwt(argc_new, argv_new);
32 } else if (strcasecmp("events", argv[1]) == 0) { 32 } else if (strcasecmp("events", argv[1]) == 0) {
33 res = input_cmd_events(argc_new, argv_new); 33 res = input_cmd_events(argc_new, argv_new);
34 } else if (strcasecmp("left_handed", argv[1]) == 0) {
35 res = input_cmd_left_handed(argc_new, argv_new);
34 } else if (strcasecmp("middle_emulation", argv[1]) == 0) { 36 } else if (strcasecmp("middle_emulation", argv[1]) == 0) {
35 res = input_cmd_middle_emulation(argc_new, argv_new); 37 res = input_cmd_middle_emulation(argc_new, argv_new);
36 } else if (strcasecmp("natural_scroll", argv[1]) == 0) { 38 } else if (strcasecmp("natural_scroll", argv[1]) == 0) {
diff --git a/sway/commands/input/left_handed.c b/sway/commands/input/left_handed.c
new file mode 100644
index 00000000..3278bd33
--- /dev/null
+++ b/sway/commands/input/left_handed.c
@@ -0,0 +1,25 @@
1#include <string.h>
2#include "sway/commands.h"
3#include "sway/input.h"
4
5struct cmd_results *input_cmd_left_handed(int argc, char **argv) {
6 struct cmd_results *error = NULL;
7 if ((error = checkarg(argc, "left_handed", EXPECTED_AT_LEAST, 1))) {
8 return error;
9 }
10 if (!current_input_config) {
11 return cmd_results_new(CMD_FAILURE, "left_handed", "No input device defined.");
12 }
13 struct input_config *new_config = new_input_config(current_input_config->identifier);
14
15 if (strcasecmp(argv[0], "enabled") == 0) {
16 new_config->left_handed = 1;
17 } else if (strcasecmp(argv[0], "disabled") == 0) {
18 new_config->left_handed = 0;
19 } else {
20 return cmd_results_new(CMD_INVALID, "left_handed", "Expected 'left_handed <enabled|disabled>'");
21 }
22
23 input_cmd_apply(new_config);
24 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
25}
diff --git a/sway/config.c b/sway/config.c
index 1c460d31..7a41a3c8 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -832,6 +832,10 @@ void apply_input_config(struct input_config *ic, struct libinput_device *dev) {
832 sway_log(L_DEBUG, "apply_input_config(%s) dwt_set_enabled(%d)", ic->identifier, ic->dwt); 832 sway_log(L_DEBUG, "apply_input_config(%s) dwt_set_enabled(%d)", ic->identifier, ic->dwt);
833 libinput_device_config_dwt_set_enabled(dev, ic->dwt); 833 libinput_device_config_dwt_set_enabled(dev, ic->dwt);
834 } 834 }
835 if (ic->left_handed != INT_MIN) {
836 sway_log(L_DEBUG, "apply_input_config(%s) left_handed_set_enabled(%d)", ic->identifier, ic->left_handed);
837 libinput_device_config_left_handed_set(dev, ic->left_handed);
838 }
835 if (ic->middle_emulation != INT_MIN) { 839 if (ic->middle_emulation != INT_MIN) {
836 sway_log(L_DEBUG, "apply_input_config(%s) middle_emulation_set_enabled(%d)", ic->identifier, ic->middle_emulation); 840 sway_log(L_DEBUG, "apply_input_config(%s) middle_emulation_set_enabled(%d)", ic->identifier, ic->middle_emulation);
837 libinput_device_config_middle_emulation_set_enabled(dev, ic->middle_emulation); 841 libinput_device_config_middle_emulation_set_enabled(dev, ic->middle_emulation);
diff --git a/sway/input.c b/sway/input.c
index ae24cb49..acd69a6b 100644
--- a/sway/input.c
+++ b/sway/input.c
@@ -24,6 +24,7 @@ struct input_config *new_input_config(const char* identifier) {
24 input->accel_profile = INT_MIN; 24 input->accel_profile = INT_MIN;
25 input->pointer_accel = FLT_MIN; 25 input->pointer_accel = FLT_MIN;
26 input->scroll_method = INT_MIN; 26 input->scroll_method = INT_MIN;
27 input->left_handed = INT_MIN;
27 28
28 return input; 29 return input;
29} 30}
diff --git a/sway/sway-input.5.txt b/sway/sway-input.5.txt
index 17b74705..e92b523a 100644
--- a/sway/sway-input.5.txt
+++ b/sway/sway-input.5.txt
@@ -34,6 +34,9 @@ Commands
34 Enables or disables send_events for specified input device. 34 Enables or disables send_events for specified input device.
35 (Disabling send_events disables the input device) 35 (Disabling send_events disables the input device)
36 36
37**input** <identifier> left_handed <enabled|disabled>::
38 Enables or disables left handed mode for specified input device.
39
37**input** <identifier> middle_emulation <enabled|disabled>:: 40**input** <identifier> middle_emulation <enabled|disabled>::
38 Enables or disables middle click emulation. 41 Enables or disables middle click emulation.
39 42