diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-10-25 16:24:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-25 16:24:32 -0400 |
commit | de074b9347b21ae0cd27afa5dfafac92707cf0d1 (patch) | |
tree | 6becd3422c2705199ae5e639020f32a9b9f334c9 | |
parent | Merge pull request #958 from Hummer12007/pango (diff) | |
parent | Add left_handed support for input devices (diff) | |
download | sway-de074b9347b21ae0cd27afa5dfafac92707cf0d1.tar.gz sway-de074b9347b21ae0cd27afa5dfafac92707cf0d1.tar.zst sway-de074b9347b21ae0cd27afa5dfafac92707cf0d1.zip |
Merge pull request #961 from t3hknr/master
Add left_handed support for input devices
-rw-r--r-- | include/sway/commands.h | 1 | ||||
-rw-r--r-- | include/sway/config.h | 1 | ||||
-rw-r--r-- | sway/commands.c | 1 | ||||
-rw-r--r-- | sway/commands/input.c | 2 | ||||
-rw-r--r-- | sway/commands/input/left_handed.c | 25 | ||||
-rw-r--r-- | sway/config.c | 4 | ||||
-rw-r--r-- | sway/input.c | 1 | ||||
-rw-r--r-- | sway/sway-input.5.txt | 3 |
8 files changed, 38 insertions, 0 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h index fe67c58c..a46f41a3 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h | |||
@@ -173,6 +173,7 @@ sway_cmd input_cmd_click_method; | |||
173 | sway_cmd input_cmd_drag_lock; | 173 | sway_cmd input_cmd_drag_lock; |
174 | sway_cmd input_cmd_dwt; | 174 | sway_cmd input_cmd_dwt; |
175 | sway_cmd input_cmd_events; | 175 | sway_cmd input_cmd_events; |
176 | sway_cmd input_cmd_left_handed; | ||
176 | sway_cmd input_cmd_middle_emulation; | 177 | sway_cmd input_cmd_middle_emulation; |
177 | sway_cmd input_cmd_natural_scroll; | 178 | sway_cmd input_cmd_natural_scroll; |
178 | sway_cmd input_cmd_pointer_accel; | 179 | sway_cmd input_cmd_pointer_accel; |
diff --git a/include/sway/config.h b/include/sway/config.h index b29fe6c5..a14b7e48 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -60,6 +60,7 @@ struct input_config { | |||
60 | int click_method; | 60 | int click_method; |
61 | int drag_lock; | 61 | int drag_lock; |
62 | int dwt; | 62 | int dwt; |
63 | int left_handed; | ||
63 | int middle_emulation; | 64 | int middle_emulation; |
64 | int natural_scroll; | 65 | int natural_scroll; |
65 | float pointer_accel; | 66 | float pointer_accel; |
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 | |||
5 | struct 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 | ||