diff options
author | Cole Mickens <cole.mickens@gmail.com> | 2016-01-17 02:53:37 -0800 |
---|---|---|
committer | Cole Mickens <cole.mickens@gmail.com> | 2016-01-19 06:51:36 -0800 |
commit | 28081b76891ddbbb825dee6c202037d78aa8f164 (patch) | |
tree | 6b7412f626f5d9f10dba8920a2543dfd3c5a662e /sway/input.c | |
parent | Add ffmpeg/imagemagick to depenency list (diff) | |
download | sway-28081b76891ddbbb825dee6c202037d78aa8f164.tar.gz sway-28081b76891ddbbb825dee6c202037d78aa8f164.tar.zst sway-28081b76891ddbbb825dee6c202037d78aa8f164.zip |
libinput
Diffstat (limited to 'sway/input.c')
-rw-r--r-- | sway/input.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/sway/input.c b/sway/input.c new file mode 100644 index 00000000..fe0d1aff --- /dev/null +++ b/sway/input.c | |||
@@ -0,0 +1,54 @@ | |||
1 | #include <ctype.h> | ||
2 | #include <float.h> | ||
3 | #include <limits.h> | ||
4 | #include <stdio.h> | ||
5 | #include <string.h> | ||
6 | #include <libinput.h> | ||
7 | #include "config.h" | ||
8 | #include "input.h" | ||
9 | #include "list.h" | ||
10 | #include "log.h" | ||
11 | |||
12 | struct input_config *new_input_config(const char* identifier) { | ||
13 | struct input_config *input = calloc(1, sizeof(struct input_config)); | ||
14 | sway_log(L_DEBUG, "new_input_config(%s)", identifier); | ||
15 | input->identifier = strdup(identifier); | ||
16 | |||
17 | input->tap = INT_MIN; | ||
18 | input->drag_lock = INT_MIN; | ||
19 | input->dwt = INT_MIN; | ||
20 | input->send_events = INT_MIN; | ||
21 | input->click_method = INT_MIN; | ||
22 | input->middle_emulation = INT_MIN; | ||
23 | input->natural_scroll = INT_MIN; | ||
24 | input->pointer_accel = FLT_MIN; | ||
25 | input->scroll_method = INT_MIN; | ||
26 | |||
27 | return input; | ||
28 | } | ||
29 | |||
30 | char *libinput_dev_unique_id(struct libinput_device *device) { | ||
31 | int vendor = libinput_device_get_id_vendor(device); | ||
32 | int product = libinput_device_get_id_product(device); | ||
33 | char *name = strdup(libinput_device_get_name(device)); | ||
34 | |||
35 | char *p = name; | ||
36 | for (; *p; ++p) { | ||
37 | if (*p == ' ') { | ||
38 | *p = '_'; | ||
39 | } | ||
40 | } | ||
41 | |||
42 | sway_log(L_DEBUG, "rewritten name %s", name); | ||
43 | |||
44 | int len = strlen(name) + sizeof(char) * 6; | ||
45 | char *identifier = malloc(len); | ||
46 | |||
47 | const char *fmt = "%d:%d:%s"; | ||
48 | snprintf(identifier, len, fmt, vendor, product, name); | ||
49 | free(name); | ||
50 | return identifier; | ||
51 | } | ||
52 | |||
53 | list_t *input_devices = NULL; | ||
54 | struct input_config *current_input_config = NULL; | ||