diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-12-07 07:31:49 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-12-07 07:35:10 -0500 |
commit | 21ce20885a6a6e9e7178778513b09fea9354c603 (patch) | |
tree | b7d763380f5b4df177ae0b8e0ca455e163bdad19 /sway/input/input-manager.c | |
parent | input skeleton (diff) | |
download | sway-21ce20885a6a6e9e7178778513b09fea9354c603.tar.gz sway-21ce20885a6a6e9e7178778513b09fea9354c603.tar.zst sway-21ce20885a6a6e9e7178778513b09fea9354c603.zip |
rename input to input-manager
Diffstat (limited to 'sway/input/input-manager.c')
-rw-r--r-- | sway/input/input-manager.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c new file mode 100644 index 00000000..285a68b8 --- /dev/null +++ b/sway/input/input-manager.c | |||
@@ -0,0 +1,79 @@ | |||
1 | #define _XOPEN_SOURCE 700 | ||
2 | #include <ctype.h> | ||
3 | #include <float.h> | ||
4 | #include <limits.h> | ||
5 | #include <stdio.h> | ||
6 | #include <string.h> | ||
7 | #include <libinput.h> | ||
8 | #include "sway/config.h" | ||
9 | #include "sway/input-manager.h" | ||
10 | #include "sway/server.h" | ||
11 | #include "list.h" | ||
12 | #include "log.h" | ||
13 | |||
14 | struct input_config *current_input_config = NULL; | ||
15 | |||
16 | struct sway_input_manager *sway_input_manager_create( | ||
17 | struct sway_server *server) { | ||
18 | struct sway_input_manager *input = | ||
19 | calloc(1, sizeof(struct sway_input_manager)); | ||
20 | if (!input) { | ||
21 | return NULL; | ||
22 | } | ||
23 | return input; | ||
24 | } | ||
25 | |||
26 | struct input_config *new_input_config(const char* identifier) { | ||
27 | struct input_config *input = calloc(1, sizeof(struct input_config)); | ||
28 | if (!input) { | ||
29 | sway_log(L_DEBUG, "Unable to allocate input config"); | ||
30 | return NULL; | ||
31 | } | ||
32 | sway_log(L_DEBUG, "new_input_config(%s)", identifier); | ||
33 | if (!(input->identifier = strdup(identifier))) { | ||
34 | free(input); | ||
35 | sway_log(L_DEBUG, "Unable to allocate input config"); | ||
36 | return NULL; | ||
37 | } | ||
38 | |||
39 | input->tap = INT_MIN; | ||
40 | input->drag_lock = INT_MIN; | ||
41 | input->dwt = INT_MIN; | ||
42 | input->send_events = INT_MIN; | ||
43 | input->click_method = INT_MIN; | ||
44 | input->middle_emulation = INT_MIN; | ||
45 | input->natural_scroll = INT_MIN; | ||
46 | input->accel_profile = INT_MIN; | ||
47 | input->pointer_accel = FLT_MIN; | ||
48 | input->scroll_method = INT_MIN; | ||
49 | input->left_handed = INT_MIN; | ||
50 | |||
51 | return input; | ||
52 | } | ||
53 | |||
54 | char *libinput_dev_unique_id(struct libinput_device *device) { | ||
55 | int vendor = libinput_device_get_id_vendor(device); | ||
56 | int product = libinput_device_get_id_product(device); | ||
57 | char *name = strdup(libinput_device_get_name(device)); | ||
58 | |||
59 | char *p = name; | ||
60 | for (; *p; ++p) { | ||
61 | if (*p == ' ') { | ||
62 | *p = '_'; | ||
63 | } | ||
64 | } | ||
65 | |||
66 | sway_log(L_DEBUG, "rewritten name %s", name); | ||
67 | |||
68 | int len = strlen(name) + sizeof(char) * 6; | ||
69 | char *identifier = malloc(len); | ||
70 | if (!identifier) { | ||
71 | sway_log(L_ERROR, "Unable to allocate unique input device name"); | ||
72 | return NULL; | ||
73 | } | ||
74 | |||
75 | const char *fmt = "%d:%d:%s"; | ||
76 | snprintf(identifier, len, fmt, vendor, product, name); | ||
77 | free(name); | ||
78 | return identifier; | ||
79 | } | ||