aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/input
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-04-18 23:19:23 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-04-18 23:19:23 +1000
commit5b30391383be7e31ae1b213f2a6095bd7a95defc (patch)
tree96ad3f77bf2538401d5538e0e0ba9c12c99f32b6 /sway/commands/input
parentMerge pull request #1819 from emersion/destroy-display (diff)
downloadsway-5b30391383be7e31ae1b213f2a6095bd7a95defc.tar.gz
sway-5b30391383be7e31ae1b213f2a6095bd7a95defc.tar.zst
sway-5b30391383be7e31ae1b213f2a6095bd7a95defc.zip
Make key repeat configurable
This creates two input commands for configuring the repeat delay and rate. Example config: input "myidentifier" { repeat_delay 250 repeat_rate 25 }
Diffstat (limited to 'sway/commands/input')
-rw-r--r--sway/commands/input/repeat.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/sway/commands/input/repeat.c b/sway/commands/input/repeat.c
new file mode 100644
index 00000000..b2f6fa46
--- /dev/null
+++ b/sway/commands/input/repeat.c
@@ -0,0 +1,55 @@
1#include <stdlib.h>
2#include <string.h>
3#include "sway/config.h"
4#include "sway/commands.h"
5#include "sway/input/input-manager.h"
6
7struct cmd_results *input_cmd_repeat_delay(int argc, char **argv) {
8 struct cmd_results *error = NULL;
9 if ((error = checkarg(argc, "repeat_delay", EXPECTED_EQUAL_TO, 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,
16 "repeat_delay", "No input device defined.");
17 }
18 struct input_config *new_config =
19 new_input_config(current_input_config->identifier);
20
21 int repeat_delay = atoi(argv[0]);
22 if (repeat_delay < 0) {
23 return cmd_results_new(CMD_INVALID, "repeat_delay",
24 "Repeat delay cannot be negative");
25 }
26 new_config->repeat_delay = repeat_delay;
27
28 apply_input_config(new_config);
29 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
30}
31
32struct cmd_results *input_cmd_repeat_rate(int argc, char **argv) {
33 struct cmd_results *error = NULL;
34 if ((error = checkarg(argc, "repeat_rate", EXPECTED_EQUAL_TO, 1))) {
35 return error;
36 }
37 struct input_config *current_input_config =
38 config->handler_context.input_config;
39 if (!current_input_config) {
40 return cmd_results_new(CMD_FAILURE,
41 "repeat_rate", "No input device defined.");
42 }
43 struct input_config *new_config =
44 new_input_config(current_input_config->identifier);
45
46 int repeat_rate = atoi(argv[0]);
47 if (repeat_rate < 0) {
48 return cmd_results_new(CMD_INVALID, "repeat_rate",
49 "Repeat rate cannot be negative");
50 }
51 new_config->repeat_rate = repeat_rate;
52
53 apply_input_config(new_config);
54 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
55}